If this is a stupid question please kick me, but I need to crowdsource experience.
I have code on two different servers - that are basically production and dev sources of the same application, but are not exactly the same and don't have the same history - that I inherited from someone whose coding standards/practices are basically non-existent. I have created a Git repository for the production code (master branch) and uploaded everything. Happy days, great times, everything's good.
Now I want to add the dev code (from the dev server) into the same repository, but as a separate branch. I've read up on git checkout --orphan <branch>
, and it seems like this might be the option for me but I'm unsure. Do I add the remote of the current repo (with the master branch already committed, updated, etc.) to the "new" git repo I initialized on the dev server, checkout an orphan branch, and then just git add -all
and push to the repo? Will adding the origin
from the existing mess with the files on the dev server in any way?
I am very comfortable with Git, but have never come across this problem, and my Google-foo has failed me.
Your help/scorn would be appreciated.
Yes, you can use git checkout --orphan dev
to realize it, and then use git add .
and git push
.
But also, there is another way, for your information (create a dev repo for dev code—dev branch, and then push it to production repo):
git remote add -f origin2 <URL for dev repo>
git checkout origin2/dev
git checkout –b dev
git push origin dev