manuelreyes60
3/25/2019 - 11:32 AM

Git - Useful Commands

Git - Useful Commands

Git Commands

  • Recommig previous commit with another user:
git commit --amend --author="My Name <my.name@myname.com>"
git pull
git push 
  • Commit Subfolder to Heroku: git subtree push --prefix <folder> heroku master

  • View Remote URLs: git remote -v

  • Remove Git Remote: git remote rm <remote-name>

  • Find Git Repository URL: git config --get remote.origin.url

  • Check local status: git status

  • Reset to latest branch head:

    Warning: This command will throw away all your uncommitted changes. For safety, you should always check that the output of git status is clean (that is, empty) before using it.

    git reset --hard

  • Open Git UI: gitk

  • Merge branch:

    • Fast-forward Merge Example:
      # Start a new feature
      git checkout -b new-feature master
      # Edit some files
      git add <file>
      git commit -m "Start a feature"
      # Edit some files
      git add <file>
      git commit -m "Finish a feature"
      # Merge in the new-feature branch
      git checkout master
      git merge new-feature
      git push origin master
      # Delete the branch
      git branch -d new-feature
      
    • Merge with commit: git merge --no-ff <branch>