读思码

日常记录


git常用命令

<p>commit的注释写错了,使用命令 git commit --amend</p> <p>撤销commit,使用命令 git reset --soft HEAD^</p> <pre><code>参数详解 --mixed  意思是:不删除工作空间改动代码,撤销commit,并且撤销git add . 操作 这个为默认参数,git reset --mixed HEAD^ 和 git reset HEAD^ 效果是一样的。 --soft   不删除工作空间改动代码,撤销commit,不撤销git add .  --hard 删除工作空间改动代码,撤销commit,撤销git add .  注意完成这个操作后,就恢复到了上一次的commit状态</code></pre> <p>从远程仓库里拉取一条本地不存在的分支时 git checkout -b 本地分支名 origin/远程分支名</p> <p>查看代码仓每人的代码统计 git log --format='%aN' | sort -u | while read name; do echo -en &quot;$name\t&quot;; git log --author=&quot;$name&quot; --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf &quot;added lines: %s, removed lines: %s, total lines: %s\n&quot;, add, subs, loc }' -; done</p> <p>查看指定时间内代码仓每人的代码统计 git log --format='%aN' | sort -u | while read name; do echo -en &quot;$name\t&quot;; git log --author=&quot;$name&quot; --pretty=tformat: --since ==2019-08-16 --until=2019-09-16 --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf &quot;added lines: %s, removed lines: %s, total lines: %s\n&quot;, add, subs, loc }' -; done</p> <p>代码pull冲突的时候 使用Git stash 将A分支暂存起来,然后在某一个分支(如master分支)新建一个分支B,然后在B分支上使用git stash pop 将修改弹出到B分支上,然后这些修改就在B分支上了。</p> <p>还可以参考 <a href="https://blog.csdn.net/sodaslay/article/details/72948722">https://blog.csdn.net/sodaslay/article/details/72948722</a> <a href="https://my.oschina.net/u/658505/blog/841576">https://my.oschina.net/u/658505/blog/841576</a></p>

页面列表

ITEM_HTML