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


Welcome


Welcome to my software development blog + personal rambling space!

I’ll be primarily posting my coding notes that I hope will be useful to someone other than me. Occasionally, I may ramble about something else.

The most useful coding notes will also be synced with my public Evernote notebook

Got something to say? Send me a message @sonny_huynh