When you run git pull on the master branch, it typically pulls from origin/master. I am in a different branch called newbranch, but I need to run a command that does a git pull from origin/master into master but I cannot run git checkout to change the selected branch until after the pull is complete. Is there a way to do this?
To give some background, the repository stores a website. I have made some changes in newbranch and deployed them by switching the website to newbranch. Now those changes have been merged upstream into the master branch, I am trying to switch the website back to the master branch as well. At this point, newbranch and origin/master are identical, but master is lagging behind origin/master and needs to be updated. The problem is, if I do it the traditional way:
$ git checkout master
# Uh oh, production website has now reverted back to old version in master
$ git pull
# Website is now up to date again
I need to achieve the same as above (git checkout master && git pull), but without changing the working directory to an earlier revision during the process.