Confused by git checkout

前端 未结 3 2100
夕颜
夕颜 2020-11-21 22:21

I am new to git and trying to wrap my head around the way branches work. According to the documentation git checkout

Updates files in the working tree

3条回答
  •  花落未央
    2020-11-21 23:05

    When you create a branch, that branch will automatically get the files of the branch you were in when you created this new branch.

    Let's say you are in master branch and you want to create a develop branch. All together should look like this:

    git checkout -b develop    # create and switch to develop branch
    touch text.txt             # create a file
    git add .                  # add file to staging area
    git commit -m "adding text.txt" 
    git checkout master
    

    And then you won't see text.txt since you are in master.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题