Git命令学习第四天

#列出所有本地分支

[root@MiWiFi-R3A-srv StudyGit]# git branch

* master

  rongbranch

#列出所有远程分支

[root@MiWiFi-R3A-srv StudyGit]# git branch -r

  origin/HEAD -> origin/master

  origin/master

#列出所有本地分支和远程分支

[root@MiWiFi-R3A-srv StudyGit]# git branch -a

* master

  rongbranch

  remotes/origin/HEAD -> origin/master

  remotes/origin/master

#新建一个分支,但是依然停留在当前分支

[root@MiWiFi-R3A-srv StudyGit]# git branch branch2

#新建一个分支,并切换到该分支

[root@MiWiFi-R3A-srv StudyGit]# git checkout -b branch3

D README.md

A ss1.txt

Switched to a new branch 'branch3'

# 新建一个分支,指向指定commit

[root@MiWiFi-R3A-srv StudyGit]# git branch branch4 README.md

fatal: Not a valid object name: 'README.md'.

[root@MiWiFi-R3A-srv StudyGit]# git commit -v

Aborting commit due to empty commit message.

[root@MiWiFi-R3A-srv StudyGit]# git branch

  branch2

* branch3

  master

  rongbranch

#新建一个分支,与指定的远程分支建立追踪关系

[root@MiWiFi-R3A-srv StudyGit]# git branch --track branch4 origin/master

Branch branch4 set up to track remote branch master from origin.

#切换到指定分支,并更新工作区

[root@MiWiFi-R3A-srv StudyGit]# git checkout branch4

D README.md

A ss1.txt

Switched to branch 'branch4'

Your branch is up-to-date with 'origin/master'.

#切换到上一个分支

[root@MiWiFi-R3A-srv StudyGit]# git checkout -

D README.md

A ss1.txt

Switched to branch 'branch3'

#建立追踪关系,在现有分支与指定的远程分支之间

[root@MiWiFi-R3A-srv StudyGit]# git branch --set-upstream branch3 origin/master

The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to

Branch branch3 set up to track remote branch master from origin.

#合并指定分支到当前分支

[root@MiWiFi-R3A-srv StudyGit]# git merge branch2

Already up-to-date.

[root@MiWiFi-R3A-srv StudyGit]# git branch

  branch2

* branch3

  branch4

  master

  rongbranch

#删除分支

[root@MiWiFi-R3A-srv StudyGit]# git branch -d branch2

Deleted branch branch2 (was 4e8d7d3).

[root@MiWiFi-R3A-srv StudyGit]# git branch

* branch3

  branch4

  master

  rongbranch

[root@MiWiFi-R3A-srv StudyGit]#

遗留问题是:

# 新建一个分支,指向指定commit,commit不知道是什么意思

你可能感兴趣的:(Git命令学习第四天)