
draft, need to orgnize
git commit
commit changes from staging area, instead of files
-a will commit changes from staging area and working dir, but that file should be tracked
–amend, amend last commit, local only, do not do amend after push
git checkout => walk around in commits and branchs
1. checkout <commit>
2. checkout <commit> <file>
3. branch
> only change working dirs
git revert
create a new commit to pretend a roll back. safe command.
git reset => delet history
1. git reset <file> => unstaging
clean up staging area, but leave working directory unchanged
--hard will also reset working directory to match last commit
2. git reset <commit>
unstaging + remove commits
--hard will also reset working directory
do not reset to the commit after a push, use revert! reset is used locally only.
danger, reset can’t undo even via reflog!
compare them
checkout just changes the working dir
reset removes the commits
revert adds a commit to perform like a roll backabove three comman only affet tracked files.
git clean => remove untracked files
always need -f to perform
need -d to delete dirs
will not delete files listed in .gitignore
git merge
merge the
git pull
git pull == git fatch + git merge remote/master
git rebase => facilitates a fast-forward merge
–rebase -i => squash history
git reflog => contains the history about rollback
in case of conflict
relax, just re-edit the conflict files, and commit again~
git remote show
git push
git push




近期评论