My shop has a goofy setup where one person code reviews and pushes, while everyone else pulls, makes changes locally, then sends changes to the one guy for review and then push.
We all keep two local branches, “main” and “work” (“main” is static and we work in “work”).
I need to know how execute the following steps:
1) Replace my “main” with the origin
2) Merge my changes from “work” into the newly updated “main”
3) Copy “main” back into “work”
The steps can be in any order, but I need to accomplish the basic idea of keeping up-to-date and working locally. I’ve been reading over the documentation, but I’m terrified to make a mistake. Any help is appreciated.
First, you shouldn’t be terrified of making a mistake. Set up some test repositories and see how things work before you work with your production code.
Assuming that your local
mainbranch matches a remotemainbranch, you should simply be able to:This will bring your local branch up-to-date with the remote branch.
You said earlier that you don’t make any changes to your “main” branch.
Having imported remote changes into your local
mainbranch, you would merge them into yourworkbranch like this:This is a pretty typical workflow: you would see something almost exactly like this if you were tracking code from an upstream source and maintaining a local set of patches.