项目中常用 git 命令

git 命令

协作

多人协作的工作模式通常是这样:

  1. 首先,可以试图用git push origin 推送自己的修改;
  2. 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并;
  3. 如果合并有冲突,则解决冲突,并在本地提交;
  4. 没有冲突或者解决掉冲突后,再用git push origin 推送就能成功!

如果git pull提示no tracking information,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream-to origin/

这就是多人协作的工作模式,一旦熟悉了,就非常简单。

小结

分支管理命令

开发分支Develop

主分支只用来分布重大版本,日常开发应该在另一条分支上完成。我们把开发用的分支,叫做Develop。

img

这个分支可以用来生成代码的最新隔夜版本(nightly)。如果想正式对外发布,就在Master分支上,对Develop分支进行"合并"(merge)。

>   git checkout -b develop master
>   # 切换到Master分支
>   git checkout master
>
>   # 对Develop分支进行合并
>   git merge --no-ff develop

这里稍微解释一下,上一条命令的--no-ff参数是什么意思。默认情况下,Git执行"快进式合并"(fast-farward merge),会直接将Master分支指向Develop分支。

img

使用--no-ff参数后,会执行正常合并,在Master分支上生成一个新节点。为了保证版本演进的清晰,我们希望采用这种做法。关于合并的更多解释,请参考Benjamin Sandofsky的《Understanding the Git Workflow》

img

协作流程

Git 如何优雅的回退代码?

Git 如何优雅的回退代码

Responses
  1. I all the time used to read post in news papers but now as I am a user of net therefore from now I am using net for articles, thanks to web. 0mniartist asmr

    Reply
  2. Just desire to say your article is as astounding. The clearness in your post is simply cool and i can assume you are an expert on this subject. Fine with your permission let me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please carry on the enjoyable work. asmr 0mniartist

    Reply
  3. Fantastic website. Plenty of helpful information here. I'm sending it to several pals ans also sharing in delicious. And naturally, thank you on your sweat! 0mniartist asmr

    Reply
  4. I'm amazed, I have to admit. Seldom do I encounter a blog that's equally educative and interesting, and without a doubt, you have hit the nail on the head. The issue is something which too few people are speaking intelligently about. Now i'm very happy I stumbled across this during my hunt for something regarding this. asmr 0mniartist

    Reply
  5. I do accept as true with all the ideas you have introduced to your post. They are really convincing and will certainly work. Still, the posts are very brief for beginners. May just you please prolong them a bit from next time? Thank you for the post. asmr 0mniartist

    Reply
  6. Dix

    Attributes of Essay-writing п‚— An excellent article needs to include the following attributes: Unity Order Brevity Style Personal Touch п‚— A composition has to be an motto, healing at a systematic style of a single topic; it must be concisely written rather than overly long, along with the design ought to by easy, clear and direct; and also... http://africaninternationalnewsmagazine.com/index.php/2021/03/30/can-i-get-a-free-fax-number/ http://apartamenty.navygroup.pl/is-harvard-good-for-art/ http://hilp-beta.thedev.se/how-do-you-gather-data-for-a-dissertation/

    Reply