While working a project I was tasked with adding two disparate code bases together. Because of long standing distance between them it’s not currently possible to merge into one branch. So this meant have a main and dev branch to manage the code bases.
The first step was setup the repo. I added the remote origin and then renamed the branch.
git config --global user.email “co@co”
git config --global user.name “cameraobscura”
git add .gitignore
git commit -m "First commit"
git branch -m master main
For the code on the other machine, I performed a similar task, but used git fetch to grab the repo contents without pulling it into the local git folder.
That’s all pretty basic, so too may be the next bit, which I learned as well. I had written a README.md file in the main branch and wanted to pull it into the dev branch.
So this is the command I needed to run on the branch I wanted to pull the file into and it worked great:
git checkout main -- README.md