DarkLite1 DarkLite1 - 6 months ago 40
Git Question

Commits to GitHub

The following workflow is what I use when I want make changes and have them committed to GitHub:

$ git checkout -b NewBranch
# Creates a new branch from origin/master for working on a specific feature and immediately switches to that branch. At this point you can add the feature you want.

$ git commit -a -m 'added a new function'
# Commits the changes to the NewBranch

$ git checkout master
$ git merge NewBranch
# Merging the changes we did in NewBranch with origin/master
$ git branch -d NewBranch
# Deletes the NewBranch as it’s no longer needed
Pushing changes to remote repository
$ git push origin
# Pushes all the changes from the master branch to the origin repository

At this point I visit the GitHub website and go to my online repository, the fork of the original project. There I click on New Pull Request, add some text and all changes are proposed in a Pull Request to the original owner.

Until here, all is working as expected. However, at this point when I make other changes locally on my client and do another
git push origin
, these changes are also immediately merged/added to the same Pull Request previously made.

How can I avoid having these new changes being added to the original Pull Request? I just want to have then online in my personal fork, not in the original repository.

Answer Source

My comment as an answer:

I normally work with the branches a little different. I push after I committed to the branch. So the branch will land within github. There you can create the Pull Request. Merge your changes to the master (without deleting the branch) and do your "private" changes on the master. Whenever you push to the Pull Requested branch the commit will automagically added to the pull request.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download