码迷,mamicode.com
首页 > 其他好文 > 详细

git 使用

时间:2018-11-26 00:15:50      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:就是   com   修改   commit   git   head   checkout   解决   回文   

1、git rm your_file

会把index和本地文件都删除掉,可以通过 git reset --hard HEAD 来进行恢复

2、git rm --cached your_file

这样只会把index中的删掉,your_file会变成untracked file,可以通过git reset HEAD来解决,就是说用最近一次的commit内容来覆盖index的内容

3、git reflog

会记录你所做过的所有操作,如果真的误删了文件,可以通过git reset --hard commit_id来找回文件

4、git checkout -b your_branch

创建本地分支your_branch并切换到your_branch

5、git push origin your_branch:your_brandh

向远端推送分支

6、git push origin :your_branch

删除远端分支

7、git branch -d your_branch

删除本地分支

8、git pull

如果产生了冲突,可以通过查看冲突文件,手动解决冲突,然后通过git add  conflict_file 告诉git已经解决了冲突

如果产生冲突后想还原成最近一次commit时的样子,可以git reset --hard HEAD,慎用,确保最后一次commit 是你想要的

9、git commit --amend

将这次修改合并到上一次修改,一般会产生新的本地分支,然后通过git push -f 强推,将远端分支更新掉

git 使用

标签:就是   com   修改   commit   git   head   checkout   解决   回文   

原文地址:https://www.cnblogs.com/longjmp/p/10017696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!