Home > OS >  I have two branches in Github: main and production. for one server I want to make git pull default t
I have two branches in Github: main and production. for one server I want to make git pull default t

Time:01-02

I have main and production branches in my GitHub repo.

I have 2 servers: one for production and the other for testing.

I want branches to match as follows:

main branch => testing server
production branch => production server

I have set up my ssh for both servers. I just want when I write: git pull in the production server to pull changes for the production branch, and when I write git pull in the testing server to pull changes from the main branch.

how can I do that?

I know I can pull the branch specifically but I want to make it automatic to prevent pulling testing changes to production by mistake.

CodePudding user response:

What about this, in production server you can do (you should create production local branch if you have not)

git branch --set-upstream-to=origin/production production

while , on testing server you can do:

git branch --set-upstream-to=origin/main main

When you run git pull in each of them, they will retrive the updates from the right branches.

  • Related