使用git我提交了一些更改,现在想将它们放到一个新的分支中。如何实现已经在多个地方解释过了,例如这里。
我的困惑更多地与此任务的本地/远程方面有关。
我首先在github上fork了一个仓库到myForkOnGitHubRepo。然后我将该仓库克隆到了我的本地PC:
local: git clone myForkOnGitHubRepo
然后我修改了源代码,提交并推送:
local: git add .
local: git commit
local: git push # (actually I used the minGW Gui for that one since the command line push issued a warning)
现在,我在我的GitHub分支上看到了本地的更改。很好。但是现在我注意到我更喜欢使用一个新分支(并且也希望在我的GitHub分支上有该新分支中的更改)。
我是否可以按照我在开头发布的链接中的说明进行操作?
local: git branch newbranch
local: git reset --hard HEAD~1 # only one commit was done
然后呢 -- 现在该怎么办?我只需再次推送吗?或者我需要明确地推送新的分支?(如果这很基础,我以前从未使用过)。
在创建新分支之前还有什么其他事情需要做吗?我的理解是,在推送之后,本地和远程处于相同状态,是这样吗?