简体   繁体   English

如何为git上的每次提交创建单独的请求请求?

[英]How do I create separate pull request for each commit on git?

I am working on project where, whenever I push my code to GitHub I need to create separate pull request for each new feature. 我正在开发一个项目,每当我将代码推送到GitHub时,我都需要为每个新功能创建单独的请求请求。

I am using git flow feature (Git flow and hotfix) function to create feature branch for each new feature I am working on. 我正在使用git flow feature (Git流和修补程序)功能为我正在使用的每个新功能创建功能分支。 But, if my pervious pull request (Previous topics feature) has not been merged, I don't know how to make another pull request so I don't merge my previous feature branch's code to new feature branch's code. 但是,如果以前的拉取请求(以前的主题功能)尚未合并,则我不知道如何发出另一个拉取请求,因此我不会将以前的功能分支的代码合并到新的功能分支的代码中。 Can someone guide me how do I make separate pull request for each new feature ? 有人可以指导我如何为每个新功能分别提出拉取请求吗? Thank you! 谢谢!

After committing on one feature branch, run 提交一个功能分支后,运行

git checkout master

before creating your new feature branch. 在创建新功能分支之前。 This will make sure you branch off of master instead of from the another feature branch. 这将确保您从master 分支而不是从另一个功能分支分支。

It sounds like you're branching off of feature branches that haven't yet been merged. 听起来您正在分支尚未合并的功能分支。

If you have, for example, a master branch plus one branch per feature, you should be branching the new features off of master, not whatever feature you're currently working on, that way the new code will be separate. 例如,如果您有一个master分支加上每个功能一个分支,则应该将这些新功能从master分支出来,而不是当前正在使用的任何功能,这样新代码便会分开。

Here is an example of how you might work on a new feature: 这是您如何使用新功能的示例:

git checkout master
git pull origin master
git checkout -b feature_name
(implement some stuff on this branch)
git add (files added)
git commit -m "describe the feature you added"
git push --set-upstream origin feature_name

Then go on github to open to pull request to merge feature_name to master. 然后在github上打开以拉​​出请求以将feature_name合并到master。

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

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