Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing to remote branch for pull request

I am lost in different articles and stackoverflow questions and I am unable to put my head around to figure out the command for GIT. Here is what i want to do

  • I created the branch from master using eclipse Git.
  • I switched to that branch
  • Made my changes

Now, I want to

  1. Commit changes locally (`git commit -m "comment"')
  2. Push to repository as branch of the Master so that i can create the pull request. Once pull approved it will be merged into the master. But how would i push my local to upstream so that the branch is created and i can issue pull request ?
like image 427
Em Ae Avatar asked Feb 03 '16 18:02

Em Ae


People also ask

How do I push a branch to a pull request?

Once you've committed changes to your local copy of the repository, click the Create Pull Request icon. Check that the local branch and repository you're merging from, and the remote branch and repository you're merging into, are correct. Then give the pull request a title and a description. Click Create.

Can you push to a branch with an open pull request?

In summary: You can push to an existing pull request if you push to the fork/branch that PR is based on. It is often possible depending on repo settings.

How do I push changes to a remote branch?

Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.

Can you push to a pull request?

Once you've created a pull request, you can push commits from your topic branch to add them to your existing pull request. These commits will appear in chronological order within your pull request and the changes will be visible in the "Files changed" tab.


1 Answers

Git has no concept of pull requests, so if you are using Git proper then you merely need to push your local branch to the remote (typically called origin).

git push -u origin my-branch-name

This will push the branch "my-branch-name" to the origin remote. The "-u" argument will set the upstream branch for you so that future pushes can be done with just "git push". At this point, others can see and review it (if you wish) before you merge it to master, like so:

git checkout master  
git merge my-branch-name  
git push

If you are talking about GitHub, the workflow is slightly different. You need to

  1. Fork the repository on GitHub
  2. Clone a copy of your fork
  3. Create your branch
  4. Commit your changes
  5. Push your changes to the fork
  6. Initiate the Pull Request from your fork in GitHub

GitHub has a lot of good documentation around this: https://help.github.com/categories/collaborating-on-projects-using-pull-requests/

like image 118
Kevin Burdett Avatar answered Sep 27 '22 22:09

Kevin Burdett