简体   繁体   English

Git工作流程(提交/推送/创建请求请求)

[英]Git workflow (commit/push/ & create pull request)

I have created a branch from master, made my changes and am now ready to commit and push back to remote master. 我已经从master创建了一个分支,进行了更改,现在可以提交并推回远程master。

Do I first need to commit my changes to my local branch 我首先需要将更改提交到本地分支吗

git commit -m "new changes, etc."

then 然后

git push

to push to the remote? 推到遥控器?

Is this first part correct? 这第一部分正确吗?

Then How do I make a pull request? 然后,我如何提出拉取请求?

Before you do anything, you should be aware that to perform a pull request, you have to do your work in a branch separate from your desired branch. 在执行任何操作之前,您应该意识到,要执行拉取请求,您必须在与所需分支不同的分支中进行工作。 Branches are super lightweight in git, and you should use them all the time. 分支在git中是超级轻量级​​的,您应该一直使用它们。 To create and switch over to a new branch, first do git branch <new branch name> , and then check it out using git checkout <new branch name> . 要创建并切换到新分支,请首先执行git branch <new branch name> ,然后使用git checkout <new branch name> Your new branch is created based on your current branch (so if you are going to make another new one that you want based on master, make sure you switch back to master first). 新分支是基于当前分支创建的(因此,如果您要基于master创建另一个新分支,请确保先切换回master)。

To commit, you need to first add the files you'd like to commit to the staging area. 要提交,您需要首先将要提交的文件添加到暂存区域。 Do this with git add <filename> . git add <filename>做到这一点。 If you'd like to add all the files you see when calling git status , you can just do git add . 如果您想添加调用git status时看到的所有文件,则可以执行git add . .

Next you can do your commit. 接下来,您可以进行提交。 I personally prefer to not add the message on the command-line for large changes, because I like to have one extra screen showing me everything that's getting committed and what specifically isn't. 我个人不希望在命令行上添加该消息以进行大的更改,因为我希望有一个额外的屏幕向我显示所有即将提交的内容,特别是未提交的内容。 I think the default editor is vi, but if you don't feel comfortable with vi, you can specify the editor through git config --global core.editor <your favorite editor> . 我认为默认编辑器是vi,但是如果您对vi不满意,可以通过git config --global core.editor <your favorite editor>来指定编辑git config --global core.editor <your favorite editor>

You're now ready to push to github! 您现在准备推送到github! Do it! 做吧! git push

Now you're ready to set up your pull request. 现在您已经准备好设置拉取请求。 Head to github and find your repo. 前往github并找到您的仓库。 Hit the pull request button. 点击拉动请求按钮。 You have two important drop downs now. 您现在有两个重要的下拉菜单。 The box on the left is the TARGET branch. 左侧的框是TARGET分支。 The box on the right is the SOURCE branch. 右边的框是SOURCE分支。 Set the left to master, and the right to your new branch. 将左侧设置为主,右侧设置为新分支。 Add a comment, review everything, then hit send pull request. 添加评论,查看所有内容,然后点击发送请求请求。 Ba-bam.

Check out this link on github for more info and some handy screen shots: https://help.github.com/articles/creating-a-pull-request 在github上查看此链接以获取更多信息和一些方便的屏幕截图: https : //help.github.com/articles/creating-a-pull-request

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

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