0

I basically have a new branch, which I want to track master in the sense that I want to be able to pull changes from, but I also do not want to push to it. To be clear here is what I want: 1. I want my branch to be able to track master and I could pull from master at any time if I wanted 2. when I pushing, I want to specify which branch to push to, either the local or the master (perhaps master will be my default push since i'm tracking it, but that is fine as long as I can specify to push to local instead.)

Thank you!

S. Nabil
  • 319
  • 1
  • 10
  • Possible duplicate of [pull/push from multiple remote locations](https://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations) – Yogesh_D Sep 29 '18 at 12:26

1 Answers1

0

IF you are using GitHub you can do this (See the end for what to do without GitHub): Create a local branch. Start committing to it. Periodically merge from Master by doing this:

git checkout master
git pull
git checkout <YourBranch>
git merge master
git push <YourBranch> -u origin <YourBranch> # if you are doing this once there is a remote just do git push.

In GitHub UI you can create a PR, this will allow you to review your code and merge it in.

If you are not using GitHub, you can then just merge to master from .

git checkout master
git merge <YourBranch>
Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
  • This isn't what I actually meant, perhaps I wasn't clear enough. I want my branch to be able to track master and I could pull from master at any time if I wanted, or pull from my local branch. I think I did that before but I can't remember how. Is there a way to continuously track master, pull from it at given time, then when I pushing, I can specify to either push it to the local branch or up to master? – S. Nabil Sep 28 '18 at 20:36
  • See - https://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations – Yogesh_D Sep 29 '18 at 12:25