Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git production and master not the same

Tags:

git

I usually work on my Master branch, and push to Production. I accidentally worked on Production branched and deployed the app. Now my Production has the latest version, Master has older version.

What should I do to update the Master branch files to the same as Production? What commands to issue?

I will be careful and work only on Master branch in future. Thanks.

like image 850
Victor Avatar asked Feb 25 '26 08:02

Victor


2 Answers

Make your current branch master and run

git merge production

or

git rebase production

See merge vs rebase for differences.

like image 109
Chandra Patni Avatar answered Feb 27 '26 22:02

Chandra Patni


If it hasn't been pulled to a remote or the remote can be overwritten, I would cherry-pick the new commits from production to master, delete the commits from production (via interactive rebase) and then do the usual rebase-merge cycle for updating production branch from master.

Check progit.org for each steps exact syntax and be careful, git is very powerful, so you can fix any screw up, but you can also screw it pretty bad.

like image 29
miguelbernadi Avatar answered Feb 27 '26 20:02

miguelbernadi