项目中常用 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. Outliff

    A standard informative article will be all about 7 webpages, constituting name page and an benchmark web page, when required. Dependent on instant and this rubric, it normally takes me anywhere from 4 hours for the moment. http://umoya-mining.com/does-your-online-dissertation-services-goals-match-your-practices/ http://pcv.trueserver.com.au/what-is-the-analysis-of-a-book/ http://www.tracceconsulenzaambientale.it/omg-the-best-buy-assignments-online-ever/

    Reply
  2. After checking out a few of the blog articles on your web site, I really like your way of writing a blog. I saved as a favorite it to my bookmark website list and will be checking back in the near future. Please check out my web site as well and let me know how you feel.

    Reply
  3. Outliff

    Attempting to produce a few research newspaper issues that are micro economics? Do not stress -. Below are a few hints about a number of those issues about what best to handle them, with guides. For lots of men and women, study creating exploration that is Schizophrenia, can be an overwhelming job. This informative article has hints https://idealglobal.com.ng/2021/05/17/at-last-the-secret-to-presentation-writing-service-is-revealed/ http://vikadnev.blox.ua/2021/05/this-study-will-perfect-your-help-with-powerpoint-presentations-read-or-miss-out.html http://ukldevserver.co.uk/college-admission-essay-writing-service-for-business-the-rules-are-made-to-be-broken/

    Reply
  4. A fascinating discussion is definitely worth comment. I do think that you need to write more about this subject, it might not be a taboo matter but typically people do not discuss these topics. To the next! Cheers!!

    Reply
  5. I was curious if you ever considered changing the layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or 2 pictures. Maybe you could space it out better?

    Reply
  6. Simply wish to say your article is as astounding. The clarity in your post is just cool and i could assume you're an expert on this subject. Well with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.

    Reply