Spidi
Spidi

Reputation: 109

Pulling a branch from another branch

So I have two branches master and develop branch. Current site is live on develop branch. But now I have added all these changes to master branch. Now on the live site master branch has no changes, so I want to pull changes of master from git. But I don't want to checkout to master as site is live. Is there a way to pull changes from master into master on the server from another branch? I executed this command

   git fetch origin master

Is it correct?

Upvotes: 1

Views: 2714

Answers (2)

Marina Liu
Marina Liu

Reputation: 38136

you can use git pull origin master:master. Because current site is live on develop branch, it may cause some merge conflict for develop branch, just abandon it. If you want to review the local latest master branch, use git checkout -f master to switch.

Upvotes: 1

Alderath
Alderath

Reputation: 3874

If the desired update of the master branch is a fast forward (which probably should be the case, since I guess you do not do code updates in the live site), you can specify a refspec:

git fetch origin master:master

This will update the local master to the state of the remote master, assuming that the update is a fast forward. Look for description of refspec in git fetch documentation. Note that this method of updating refs cannot be used if local and remote master have diverged.

Upvotes: 1

Related Questions