0

Suppose I created a pull request on a new branch, then I need to push some additional updates in the same pull request on the same new remote branch, here are my operations, wondering if correct or any better solutions? Thanks.

git checkout -b newFooBranch git add <name of file changed> git commit -m 'add some initial changes' git push origin newFooBranch // make some changes git add <name of same file changed> git commit -m 'add some new changes on the same file' git push origin newFooBranch 

regards, Lin

9
  • 2
    Yes, just push the additional commits - GitHub will update the PR. Commented Jul 28, 2016 at 2:15
  • 2
    you should add "-u" parameter, as follows: git push origin -u newFooBranch This way, git will track your current branch to remote branch. Without "-u" it will push without tracking (your current branch would be not "connect" with the remote branch and you'll need to specify which remote branch you want to push next time) Commented Jul 28, 2016 at 2:37
  • @Klaus, thanks and vote up, you mean add -u to which push in my above commands? I have two push commands. Commented Jul 28, 2016 at 3:06
  • 1
    Literally exactly what you have already. Why don't you just try it? Commented Jul 28, 2016 at 12:01
  • 1
    @LinMa, you can put "-u" in either of your commit commands. That parameter set your local newFooBranch branch to be tracked to newFooBranch on the remote server. You only need to push with "-u" once. Commented Jul 31, 2016 at 9:15

2 Answers 2

1

@LinMa, You could add "-u" parameter to either of your commit commands, the command will become:

git push origin -u newFooBranch 

The "-u" parameter tells git to track (connect) your current local "newFooBranch" to the "newFooBranch" on the remote server. You only need to push with "-u" once for every newly created branch.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for all the help Klaus, mark your reply as answer.
1

If the changes are related to the previous change, I would recommend rather using:

git add <some changes related to previous commit> git commit --amend 

This will just append the changes to the previous commit, that way you don't litter your branch with changesets that mean little on their own.

If you have already pushed commits that could have be rolled into one commit, use rebase to either squash or fix your commits.

1 Comment

@LinMa No problem :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.