Pushing to remote branch for pull request
Asked Answered
R

1

7

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 ?
Range answered 3/2, 2016 at 18:19 Comment(4)
git push origin mybranchname? Sorry, but it's not clear what's exactly the problem here.Washout
would it create the new branch in remote ? I was worried that what if i mess up the branchRange
Yes, it creates a new branch in remote. How can it mess up the branch?Washout
@Washout Nope, you don't have the permission to create branches on other people's accounts. You can only push the new branch in your own fork. Then you can either open PR to merge it with the upstream's: MASTER, or ask the maintainer to create the corresponding new branch him/her-self.Hyonhyoscine
S
7

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/

Sharonsharona answered 3/2, 2016 at 18:35 Comment(1)
Are you saying that Git doens't handle pull requests? What is this article about, then? I'm confused.Tessera

© 2022 - 2024 — McMap. All rights reserved.