首页 > 解决方案 > 更改当前分支并提交到 Git 中的新分支

问题描述

我已经通过 bitbucket 在 Git 中手动创建了一个新分支 (C)。现在我想将更改从分支 A 推送到分支 C。

我现在在目录 A 上并提交并推送了一个更改到这个分支。

directoryA > git status
On branch A
Your branch is up-to-date with 'origin/A'.
nothing to commit, working directory clean

现在我去了目录 B。当我这样做git status时,它连接到分支 B,但我希望这个目录连接到分支 C

directoryB > git status
On branch B
Your branch is up-to-date with 'origin/B'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitignore
        modified:   config/development.json

no changes added to commit (use "git add" and/or "git commit -a")

所以我应该git fetch && git checkout C留在目录B然后提交和推送。

请建议。非常感谢任何帮助。

标签: git

解决方案


您是否尝试过您建议的方法,它会起作用。要清楚再次提供详细信息

 git fetch && git checkout C 
 git commit -am "what ever message you want to put" 

上面的命令将提交.gitignore,config/development.json,您可以推送到远程。


推荐阅读