0

I've searched all over the site and seen several examples that are extremely close, but don't answer the last part of the question I have. Is there a way to perform

    git pull origin master:master

while I have a feature branch checked out and not merge the changes into my feature branch? This call keeps my local master in sync with the origin master, but just before it finishes it will also merge the origin master changes into my feature branch.

Mr. Anderson
  • 165
  • 2
  • 10
  • Possible duplicate of [What is the difference between 'git pull' and 'git fetch'?](https://stackoverflow.com/questions/292357/what-is-the-difference-between-git-pull-and-git-fetch) – phd May 10 '18 at 22:19
  • In short: `git fetch origin master:master`. – phd May 10 '18 at 22:19
  • I don't want to fetch, I want to pull to update my local copy of master, but not my feature branch which is a fork of master with additional changes. Also as I knew this would get flagged as possible dupe, I opened the question saying I have already searched and not found an answer to the last part of my question *and leave current branch untouched* – Mr. Anderson May 11 '18 at 15:24

1 Answers1

1

This may be what you want.

git stash 
git checkout master
git pull origin master:master
git checkout MY_TOPIC_BRANCH 
git stash pop

Look up the 'git help fetch'. the above comment by phd is closest to what you want. It will bring in the latest 'origin/master' branch, but leave your 'master' branch and 'MY_TOPIC_BRANCH' unchanged. you can merge later with

git commit MY_TOPIC_BRANCH
git checkout master
git diff master origin/master 
-- if you like what you see then -- 
git merge origin/master
Gregg
  • 2,444
  • 1
  • 12
  • 21
  • I think this might be the best solution. I was hoping for a flag to stop the automatic merge or something similar, but I didn't see anything like that in the git documentation so I figured it didn't exist. Just wanted to make sure I wasn't missing something simple . Thank you very much. – Mr. Anderson May 14 '18 at 13:10
  • See the git documentation about the difference between 'pull' and 'fetch' – Gregg May 17 '18 at 19:08
  • see my changes to the answer above – Gregg May 17 '18 at 19:24