admin 管理员组文章数量: 1086019
2024年4月28日发(作者:avalonedit语法文件xshd)
查看某个文件的修改
git log -p filename
git blame filename是查看目前的每一行是哪个提交最后改动的,最好通过less管道输出
查看每个commit都对那个文件做了修改
git log --stat
撤销:
-------------------
1) 撤销修改,但是还没有commit
git checkout
2) 撤销已经commit的修改
git reset --soft
git reset --hard
3) Revert some existing commits
git revert
例如git revert HEAD,恢复最后一个commit的修改
4) If you just want to restore just one file, say your hello, use git-checkout
$ git checkout -- hello
$ git checkout HEAD hello
The first command restores hello to the version in the index, so that
“git diff hello” returns no differences. The second command will restore
hello to the version in the HEAD revision, so that both “git diff
hello” and “git diff —cached hello” return no differences.
git rm --cached
git rm 会删除index的同时也会删除文件,--cached就不会了,但是你commit,push了以后远端仓库也
没有相应的文件了
pull/push
-------------------------------------------------------------------
git diff HEAD^ HEAD >
git apply --check -v
git apply
Download src:
git clone steven@project:/home//projectname
#git config --global "Steven Yang"
#git config --global "mqyoung@"
git config "your name"
git config yourname@email_server
git config vim
git config "less -N"
git config true
git config checkout
git diff tag 比较tag和HEAD之间的不同。
git diff tag file 比较一个文件在两者之间的不同。
git ag2 比较两个tag之间的不同。
git diff SHA11..SHA12 比较两个提交之间的不同。
git diff tag1 tag2 file or
Git HowTo
git diff tag1:file tag2:file 比较一个文件在两个tag之间的不同。
log:
----------------------------------------------------------
git log file 查看一个文件的改动。
git log -p 查看日志和改动。
git ag2 查看两个tag之间的日志。
git log -ag2 file 查看一个文件在两个tag之间的不同。
git log tag.. 查看tag和HEAD之间的不同。
git commit -a -e 提交全部修改文件,并调用vim编辑提交日志。
git reset HEAD^ or
git reset HEAD~1 撤销最后一次提交。
git reset --hard HEAD^ 撤销最后一次提交并清除本地修改。
git reset SHA1 回到SHA1对应的提交状态。
Update:
git pull
Add:
git add [filename]
git add *
git commit -a -m "comment"
git push
#更详细的log
git log -p
#create a new branch
git branch my_new_branch
#show your branches
git branch
#switch to your branch
git checkout my_new_branch
#merge the master code with into the branch code
#If conflict occur, please do the merge manually
git checkout master
git merge my_new_branch
#Delete a branch
git branch -d my_new_branch //Delete a branch. The branch must be fully merged
in HEAD.
git branch -D my_new_branch //Delete a branch irrespective of its merged
status.
git reset --soft HEAD^ 撤销最近一次提交
#See the type of the commit
steven@steven:~/xmlinux$ git cat-file -t 19f00f070c17584b5acaf186baf4d12a7d2ed125
commit
#See more info
版权声明:本文标题:Git HowTo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1714244630a671493.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论