gitの - シニア

共通コマンド

ブランチを作成 - gitのブランチ

単にブランチの現在の名前のgit branchコマンドのディスプレイを使用、特長1使用Gitのブランチ特長1と呼ばれるブランチ、gitのチェックアウトの特長1 Aハンドオフ特長1支店、gitのチェックアウト-b特長2を作成した上記の二つのコマンドの組み合わせである、作成そして、特長2ブランチに切り替えます。

$ git branch # 查看
* master

$ git branch feature1 # 创建
$ git branch
* master
  feature1

$ git checkout feature1 # 变更
Switched to branch 'feature1'

$ git checkout -b feature2 # 创建 + 变更
Switched to a new branch 'feature2'

削除された枝 - gitのブランチ-d

マージ支店 - gitのマージ

$ git branch
* feature2
  feature1
  master

$ git merge feature1 # 此时需要填写 merge 信息,然后就成功将 feature1 的内容合并到 feature2 中

$ git branch -d feature1 # 此时 feature1 就消失了,后面的编号代表它 commit 的值前 7 位
Deleted branch feature1 (was 651f232).

ブランチは、競合をマージ

枝は、文書に異なる修飾を有する、分岐Aのファイルが書き込まれた主に二つの枝に、分岐Bを競合をマージするとき、ファイルが書き込まれ、AB、分岐ファイルがC AC、合併の時に書かれています競合上のコンテンツは、この時間は、手動で合併プロセスを完了するために、内容を変更する必要があります。

# 在 A 分支写下 a.txt 文件,内容是 a
$ git branch
* A
$ cat a.txt
a

# 创建 B 分支,修改 a.txt 文件,内容是 ab
$ git checkout -b B
Switched to a new branch 'B'
$ cat a.txt
ab
$ git branch
  A
* B

# 回到 A 分支,创建 C 分支,修改 a.txt 文件,内容是 ac
$ git checkout A
Switched to branch 'A'
$ git checkout -b C
Switched to a new branch 'C'
$ cat a.txt
ac

# 回到 B 分支,合并 C 分支,此时产生冲突
$ git checkout B
Switched to branch 'B'
$ git merge C
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
Automatic merge failed; fix conflicts and then commit the result.

# 查看冲突的文件内容,不做修改,重新 commit
$ vim a.txt
<<<<<<< HEAD
ab
=======
ac
>>>>>>> C

$ git add .
$ git commit -m "abc"

# 此时可以看到合并已经完成
$ cat a.txt
<<<<<<< HEAD
ab
=======
ac
>>>>>>> C

$ git log
commit 6019def448ca10da6aa462c0b1ed7f1b1a768bbd (HEAD -> B)
Merge: b088741 fa4d442
Author: ChenBin113 <[email protected]>
Date:   Sun Dec 1 17:55:05 2019 +0800

    abc

commit fa4d442a66125c89af5cabf946a669af9ba256ba (C)
Author: ChenBin113 <[email protected]>
Date:   Sun Dec 1 17:53:06 2019 +0800

    ac

commit b088741babb987489d27a558978b63df3144ba0e
Author: ChenBin113 <[email protected]>
Date:   Sun Dec 1 17:50:34 2019 +0800

    ab

commit d34197eb7937fb2198676e8b9f2c80e061433f96 (A)
Author: ChenBin113 <[email protected]>
Date:   Sun Dec 1 17:40:25 2019 +0800

    A: a

# 删除 C 分支
$ git branch -d C
Deleted branch C (was fa4d442).

gitのタグ

v1.0の-a gitのタグは、現在のタグは、v1.0のマークをコミットマークされ、通常のメジャーリリースを記録するために使用される表します。

おすすめ

転載: www.cnblogs.com/chenxianbin/p/11967948.html