Skip to content

Instantly share code, notes, and snippets.

@pboksz
Last active December 12, 2015 07:49
Show Gist options
  • Save pboksz/4739796 to your computer and use it in GitHub Desktop.
Save pboksz/4739796 to your computer and use it in GitHub Desktop.
Some neat git tricks that I use a lot.

##When commits are still local

####Adding or changing a file to the most recent commit

git add <file-name>
git commit --amend

####Fixing the most recent commit's message

git commit --amend -m "<new-commit-message>"

####Fixing a commit that is not the most recent

git checkout <commit-that-needs-fixing>
<make-said-changes>
git add <file-name>
git commit --amend
git rebase --onto HEAD <commit-number-you-used-above> <branch-name-you-were-working-on>

##Tracking remote from branch

git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment