• 关于Git的仓库、分支的一点理解

    2016/05/15 zzjack

Git使用分支的策略来进行协作。git init初始化会生成.git的隐藏文件夹,包含了分支、标签、日志、操作记录等所有信息,并且会默认创建一个master的分支,但是只有git commit提交了以后才会有真正分支的概念。比如:

git init    # 创建master分支

touch test.txt

git checkout -b test

git branch    # master 分支被删除

git add test.txt

git checkout -b test2

git branch    # test分支也会被删除

 

参考:

Why does my ‘git branch’ have no master?

master is just the name of a branch, there’s nothing magic about it except it’s created by default when a new repository is created.
You can add it back with git checkout -b master.        —Matt Curtis

2 收藏


直接登录