|
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 $branchname
|
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 directories) 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/path/to/zipfile.zip master
|
git export, exporting the source code as with “svn export”
|
|
|
git checkout -- .
|
Discard all my unchecked in changes
|
|
|
git config --global push.default current & git push -u
|
Create a new remote branch from the current local one
|
|
|
git rev-list -n 1 HEAD -- $filename & git checkout $deletingcommitid^ -- $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.fileMode false
|
Make git ignore permissions/filemode changes
|
|
|
git config --global credential.helper cache
|
Get git to remember my password when checking out with https
|
|
|
git show $commitid:$filename
|
Take a quick look at an old revision of a single file
|
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.