Skip to content

Instantly share code, notes, and snippets.

@nulpunkt
Last active June 1, 2018 09:33
Show Gist options
  • Save nulpunkt/97190d7eff10dd6baaacc8db6ce587d5 to your computer and use it in GitHub Desktop.
Save nulpunkt/97190d7eff10dd6baaacc8db6ce587d5 to your computer and use it in GitHub Desktop.
Notes for friday school

Git good!

Adding files

git add -p will let you add changes to parts of a file

git commit -a will commit all changes to all files known to git

Regret!

I want to change what I did in the previous commit. Make everything look like you want it to look. Add the changes and commit with: git commit --amend this will change the last commit you did.

You could also move HEAD one back: git reset --soft HEAD~1 This will let you make your changes, add them and commit them as well. Probably easier if you want to remove a file :)

I added a file, but I don't want to commit it: git reset <path>

My history looks like crap!

In git you can rewrite history!

git rebase -i HEAD~2 will allow you to rewrite the history of the two last commits. This include removing the commits, rewrite commit messages and squash them.

All is lost :(

git reflog will show all changes

You can undo what you did with: git revert <commit>

If you want to undo a merge: git revert -m1 <commit>

Remember: If you revert a change and you want your change back, you must revert the revert :) You can look back, but you must go forward :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment