git developed for everyday use summary

git branch development

Line, there are three branches: master, java, php branch. As shown below

 

 

 

 

 

 

Where the master branch: Blank

 

 

 

php branches: blank

 

 

 

 Java branch:

 

 

 

 Demand a 1:

Php pulling to the local branch code, create a.txt file, and the file is submitted to the distal end b.txt;

1.1 Copy url

 

1.2 Open the terminal clone

 

 

 

1.3 View remote branch file

 

1.4 b.txt file and create a.txt

 

1.5 pushed to the distal end

 

 

 

Modify the configuration file:

  

Enter edit:

 

Press Esc to exit editing, press:! Wq exit.

Then view status, and submits:

 

 

 

 

1.6 View remote branch

 

 

 

 

2 Demand II:

Assume a.txt is a project, b.txt is another project. Now you are doing first project a.txt, half-done, and all of a sudden, another project b.txt the bug you need to modify the task more urgent, then you need to pause a.txt of development, to develop b project, to deal with this bug a.txt need to modify the file, edit and add b1.txt b.txt file.

Ideas: In the above local branch in php create two branches, a development of a project, a project to develop b, and finally merge merge onto php this branch, commit push.

2.1 Creating a branch, and branch b, respectively, to develop two projects or functional modules

 

2.2 handover branch to a, edit files a.txt

 

2.3 a.txt edit the file and exit

 

View:

At this point in time we need to deal with bug b project, editing b.txt, modify files and add b1.txt file a.txt

2.4 The author a.txt saved to a local warehouse

 

 

 

 

2.5 handover branch b, b project development

 

View a.txt content, see if you can see the code submitted on a branch just committed?

 

 

 

 

The answer is: just do not see the face and edit the contents of a.txt file on a branch.

2.6 Editing b.txt, b1.txt new file, and then to modify a.txt

 

 

 

 

 

 

 

2.7 The author branch b

2.8 Merge (merge) to php branch

Note that you need to pull the front merge

 

Merge merge operation: in fact, are first incorporated into a local branch, and push to the distal end of the corresponding branch.

2.9 View branch code php

 

At this time, bug modification, it is time to submit to the distal end of the code:

 

Check remote branch situation:

 

2.10        现在可以在回去继续开发a项目,切换分支到a进行继续开发编辑

2.11        编辑a.txt文件,然后提交

 

 

2.12        Merge到php本地分支

 

2.12.1 解决冲突

       假设你之前没有解决过冲突;

      

思路:根据提示,走着看看着走:

 

 

 

 

根据给出的提示:

       执行 git merge –abort :回到合并前的状态;

既然说a.txt 文件冲突,那就查看a.txt文件,进行手动解决冲突:

 

 

 

 

2.12.2 编辑a.txt文件进行冲突解决

 

 

 

 

查看远端代码:

 

 

 

 

2.12.3 查看状态,还是处于冲突中,但是已经将冲突解决了,所以可以直接提交了并推送到远端了。

 

 

 

 

2.13        推送到远端php分支

 

 

 

 

2.14        pull并查看a.txt文件,验证冲突是否解决

 

 

 

 

2.15        此时查看本地a分支,与b分支的代码情况:

 

 

 

 

发现a分支,与b分支还是之前的代码,并没有更新;

要想实现分支与php代码一直,需要merge:

2.16        同步a,b分支与php分支的代码

  

同步php本地仓库到本地a分支代码仓库:

 

3     合并到远端master分支

3.1 先查看远端maste分支下代码情况

 

还是空空如也。

3.2 创建本地master分支仓库

 

3.3 将远端的remotes/origin/php 分支 合并到master分支

3.4 推送到远端master分支

 

查看远端分支:

 

 

 

终端查看:已经合并上去了。

 

 

 

4        Git命令解析:

4.1 克隆

git clone [–b 远端分支名] https://github.com/vhviqd/java26.git

其中[]表示可选,如果不写,默认是master分支。

4.2  创建远端分支

git push origin 本地分支名

 

 

 

若想创建一个远端分支名与本地分支名不一样的。

git push origin 本地分支名:远端分支名

 

 

 

4.3 删除远端分支

git push origin :远端分支名

 

 

 

4.4 查看版本记录

git reflog

 

 

 

4.5 切换版本

git reset --hard 版本号

 

 

 

利用版本切换可以使代码回退到之前的版本。只是本地分支对应的仓库的版本回退,并不涉及远端,只有push推送了,才会更新也断代码。

4.6 拉取代码

git pull  :更新本地代码,使得与远端代码保持一致

4.7 推送代码

git push   :把本地代码推送到远端分支。

Guess you like

Origin www.cnblogs.com/vhviqd/p/11488691.html