Show Menu
Cheatography

Git mistakes Cheat Sheet by

Main

git commit --amend
I wrote the wrong thing in a commit message
If the commit hasn’t been push you can do the following, which will allow you to edit the message on the most recent commit
git reset --hard HEAD~1
How can I undo the last commit?
HEAD~1 means HEAD-1 commit. It should be noted that this is the nuclear option, and any changes you made will be discarded.
git reset --soft HEAD~1
If you want to keep your changes in the working tree use
git revert HEAD~1..HEAD
If you’ve already published your commits, you should use revert. This is create new commits undoing the last change
git revert $commitid
If you’ve already published your commits, you should use revert. This is create new commits undoing the last change
git push origin --delete $branc­hname
Delete a Git branch remotely
git reset $filename
How do I undo a ‘git add’ before committing
git clean -f -d
Remove all local untracked files (and direct­ories) from your local clone
git branch -m $oldname $newname
Rename local branch
git reset --hard commitid
Revert to a previous Git commit
git fetch --all & git reset --hard origin­/master
Over-write local files when doing a git pull
git archive --format zip --output /full/­pat­h/t­o/z­ipf­ile.zip master
git export, exporting the source code as with “svn export”
git checkout -- .
Discard all my unchecked in changes
git config --global push.d­efault current & git push -u
Create a new remote branch from the current local one
git rev-list -n 1 HEAD -- $filename & git checkout $delet­ing­com­mitid^ -- $filename
Restore a deleted file, First find the commit when the file last existed
git checkout $commitid $filename
Revert a single file to a specific previous commit
git config core.f­ileMode false
Make git ignore permis­sio­ns/­fil­emode changes
git config --global creden­tia­l.h­elper cache
Get git to remember my password when checking out with https
git show $commi­tid­:$f­ilename
Take a quick look at an old revision of a single file
Tudo que tem o simbolo "­$" na frente deve ser mudado de acordo com a necess­idade
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.