Useful Git Commands


Working with ’origin’ Remote Branch

NOTE: The name of my remote branch is called origin. Substitute origin for name of remote branch you are working with.

Push current branch to repo

$ git push

Push branch to ’origin’ repo

$ git push origin [branch]

Remove branch from ’origin’ repo

$ git push origin :[branch]

Pull new branch from ’origin’ repo, create new local

$ git checkout -b [local_branch] origin/[remote_branch]

Pull branch changes from ’origin’ repo, merge with current branch

$ git pull origin [branch]

Stashes

Add

$ git stash

Use Latest

$ git stash pop

Show

$ git stash list

Use Specific Stash

$ git stash apply stash@{[index]}

Delete Specific Stash

$ git stash drop stash@{[index]}

Uncategorized

Modify last commit

# do NOT use if commit has been pushed to remote.
$ git commit --amend -m '[message]'

Tagging

$ git tag -a [tag name] -m '[tag message]'

Revert specific commit

$ git revert [commit]

More Information

comments powered by Disqus