简体   繁体   English

将更改推送到分支而不合并?

[英]push changes to a branch without merging?

Let's say I want to work on a branch, so a create one:假设我想在一个分支上工作,所以创建一个:

git branch <name_branch>

then I work on it git checkout name_branch然后我处理它git checkout name_branch

then I commit the changes:然后我提交更改:

$ git add .
$ git commit -m "adding a change from the feature branch" 

But I still have some work to be done on the branch, so I don't want to merge it yet, but I need to get it online, will git push branch_name do the trick?但是我在分支上还有一些工作要做,所以我还不想合并它,但我需要让它在线, git push branch_name做吗? or should I merge with he master branch after each commit and then push the changes as recommended in the basic workflow?或者我应该在每次提交后与他的主分支合并,然后按照基本工作流程中的建议推送更改?

If it's truly a new branch like you said above, it will not merge into master.如果它真的像你上面说的那样是一个新分支,它不会合并到 master 中。

The remote repository should create its own new branch with the changes where you can merge branches later.远程存储库应该使用更改创建自己的新分支,您可以稍后在其中合并分支。

I would not merge to master just to save my work-in-progress -- master should always be clean.我不会为了保存我正在进行的工作而合并到master —— master应该总是干净的。 With Git, branches (local and remote) are cheap.使用 Git,分支(本地和远程)很便宜。 If you want to back-up your local branch to the remote, just do this (assuming your remote is named "origin" and you have <branch_name> checked out):如果您想将本地分支备份到远程,只需执行以下操作(假设您的远程名为“origin”并且您已检出 <branch_name>):

git push -u origin <branch_name>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM