0

我只是使用本教程学习 git 版本控制:

http://net.tutsplus.com/tutorials/other/easy-version-control-with-git/

现在我做了 2-3 次提交,然后切换到另一个分支。然后我又做了 2-3 次提交。

gitk -all但我仍然在or中看到一条简单的直线git log --graph

可能出了什么问题?

user@comp:~/Documents/trygit2$ git add .
user@comp:~/Documents/trygit2$ git commit -m 'first commit'
[master (root-commit) d525eb9] first commit
 0 files changed
 create mode 100644 file1
user@comp:~/Documents/trygit2$ git add .
user@comp:~/Documents/trygit2$ git commit -m 'second commit'
[master 5fe0bba] second commit
 0 files changed
 create mode 100644 file2
user@comp:~/Documents/trygit2$ git branch branch1
user@comp:~/Documents/trygit2$ git checkout branch1 
Switched to branch 'branch1'
user@comp:~/Documents/trygit2$ git add .
user@comp:~/Documents/trygit2$ git commit -m 'branch commit1'
[branch1 84e162e] branch commit1
 0 files changed
 create mode 100644 branchfile
user@comp:~/Documents/trygit2$ git add .
user@comp:~/Documents/trygit2$ git commit -m 'branch commit 2'
[branch1 bb7a619] branch commit 2
 0 files changed
 create mode 100644 branchfile2

user@comp:~/Documents/trygit2$ git status
# On branch branch1
nothing to commit (working directory clean)
user@comp:~/Documents/trygit2$ git log --graph
* commit bb7a619990925782c37921e80c3aaf8310530de2
| Author: = <=>
| Date:   Fri May 17 16:33:58 2013 +0530
| 
|     branch commit 2
|  
* commit 84e162e186dc1a7d51ac48eaf3d05748178da803
| Author: = <=>
| Date:   Fri May 17 16:33:42 2013 +0530
| 
|     branch commit1
|  
* commit 5fe0bbaf72b3db9f456c5687efd425b0dac28466
| Author: = <=>
| Date:   Fri May 17 16:32:50 2013 +0530
| 
|     second commit
|  
* commit d525eb935deb4899293db64bdbc350add21bc943
  Author: = <=>
  Date:   Fri May 17 16:32:28 2013 +0530

      first commit
4

2 回答 2

4

没有错。你有一个直接的提交行:

A-->B-->C-->D-->E-->F
        ^           ^
   BranchA        BranchB

如果您现在结帐BranchA并进行一些提交,您将看到分支在gitk --all

于 2013-05-17T11:03:52.823 回答
1

这是因为您的提交历史可以以直线显示。

* 5 (HEAD, my-branch)
* 4
* 3 (master)
* 2
* 1

如果你提交一些东西来掌握它会变得很有趣

* 6 (HEAD, master)
| * 5 (my-branch)
| * 4
|/
* 3
* 2
* 1

这不能再以直线显示。

于 2013-05-17T11:06:04.603 回答