1. Check unpushed commit
git log origin/master..HEAD
git diff origin/master..HEAD
2.Revert uncommitted changes
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories.
git clean -fd
3. unstaging a staged file
git reset HEAD <file>
4. Amend last commmit :
$ git commit -m 'initial commit' $ git add forgotten_file $ git commit --amend
5. show diff of a commit with commit #:
git show 7f1ef64274b588b8d7430f31fbf915257a605f456. reset unpushed commit :
delete the most recent commit:
git reset --hard (HEAD~1 or head number)
Delete the most recent commit, without destroying the work you've done:
git reset --soft (HEAD~1 or head number)
7. revert a single file :
git checkout filename
git reset --hard will revert all changes.
8. Avoid others' changes in my check in records
git checkout master
git pull -rebase
git checkout -b your-branch
git commit -m "something"
git commit -m "more things"
git checkout master
git pull -rebase (put your commit on the top of the stack) or git pull -r
git checkout your-branch
git rebase master
git checkout master
git merge your-branch ==> fast forward push
9. git rebase -i HEAD~2
combine last two commits
No comments:
Post a Comment