如何git在master完成工作后推送到分支?

How to git push to branch when work is done in master?

超级菜鸟的问题但是....

您可以复制修改后的文件并将其粘贴到其他位置,以免丢失更改。然后,还原您的更改,切换到您要提交的分支,将您的文件粘贴到它们所属的文件夹中,然后将您的更改提交到该分支。

如果您不想影响 master 分支,现在是为您的提交创建一个新分支的时候了。

git checkout -b my_branch
git add .
git commit -m "This commit will be on the `my_branch` branch instead of `master`

我假设您想将这些更改移动到 new/experimental 分支

git checkout -b my_new_branch
git commit

正如之前其他人所说,结帐并提交到一个新分支

git checkout -b mybranch
git add mychangedfiles
git commit

如果您已经设置了要推送到的远程,您现在可以使用

推送您的新分支
git push -u myremote mybranch

这也将此分支设置为跟踪远程上推送的分支(-u 选项)。

如果您还没有设置遥控器,您可以使用

git remote add myremote myremoteurl