如何用git切换回'master'?

Dis*_*sco 113 git

我做了第一次提交; 然后创建了一个分支(比如说branch1).

在这个分支中,我创建了一个目录'example'并提交.在GitHub中,我看到了我的新分支和我添加的新目录"example".

现在我想知道我怎样才能'同步'回主人; 所以删除了'example'文件夹(因为它在master上不存在).

编辑:find . -type d -empty -exec touch {}/.gitignore \; 做了这个工作.

Mat*_*ell 199

你需要签出分支:

git checkout master
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅Git备忘单.

编辑:请注意,git不管理空目录,因此您必须自己管理它们.如果您的目录为空,请直接将其删除.


小智 7

将带您到 master 分支。

git checkout master

要切换到其他分支(忽略方括号,这只是为了强调目的)

git checkout [the name of the branch you want to switch to]

要创建一个新分支,请像这样使用-b(忽略方括号,这只是为了强调目的)

git checkout -b [the name of the branch you want to create]


小智 5

根据Git备忘单,您必须先创建分支

git branch [branchName]
Run Code Online (Sandbox Code Playgroud)

然后

git checkout [branchName]
Run Code Online (Sandbox Code Playgroud)

  • 我想你可以再看看这个问题 (3认同)