30 November 2014

git rebase -i HEAD~4, rebase the last 4 commit, you can edit, squash, pick ….

  1. when we want to split one commit into two commit before push to remote.
edit the commit, and save

git reset --soft HEAD^

this give you the opptunity to recommit the file, you can use this command to split the commit
  1. when we want to merge two commit into one
git rebase -i HEAD~4

reword the first commit then fixup the commit you want to merge into then save

git reset –soft and git reset –hard

–soft will reset the commit to index, you still have the changes you did

–hard will reset the commit to workspace, you lost the changes, you can use git reflog to restore the change

use git reflog to find the commit hash

and use git reset --hard hash to restore to that point

HEAD^ === HEAD~ means the parent of this commit

HEAD^2 means the second parent of this commit

git blame is useful when you want to see the detail of the file

git cherry-pick can be used when you just want one commit of three, you can cherry pick one of it

git stash save --keep-index git stash save --include-untracked

git symbolic-ref HEAD --short git show-ref --heads master git rev-parse --git-dir git merge-base src dest git update-ref git commit-tree git write-tree

show author info only

git –no-pager show -s –format=’%an <%ae>’ b5c69b0

show modified files of one commit

git diff-tree –no-commit-id –name-status -r b5c69b0



blog comments powered by Disqus