Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.
$ git status $ git status . -u no # don't display the untracked files . mean current git repo
1
$ git commit -s " init commit of repo";
1
$ git log
revert a commit
1
git revert commit-id
start a branch
1 2 3 4
git branch my-branch-name # how to name a branch ,name it after a real co-workers'name ,if it's only for him/her, then you can commit on that branch won't mess things up # in the commit log you can describe what this commit about , it's usually for debugsome functions or purly for uploading code, or name it # after a feature function you are developing, is great
how to use a git patch
1 2 3 4 5 6
# this is git foramt patch version contains commit-msg git format-patch commit-id git apply/am xxx-001-patch # this is old fashion diff vpatch ersion git diff > xxx.diff git am/apply xxx.idff
git 小技巧
暂存
1
$ git stash
挑选
1
$ git cherry-pick commit-id
变基
1
$ git rebase -i commit-id
查看文件变更
查看 hello.c 文件中的10到20行的修改记录
1
$ git blame -L 10,20 hello.c
从历史版本中取出某个文件
从历史版本(commit-id)中取出hello.c
1
$ git checkout commit-id hello.c
commit it when debug or develop has been done some of it , at the last time you can rebase it or git reset –soft it
1 2 3 4 5 6
# use the last commit-id git commit --amend # git reset --soft # git reset --mixed