How to set a git branch to push to a remote computer with a different branch name and pull from a completely different URL

The local git repo should pull from one server. Then it needs to direct the specific branch to the browse repository with a different branch name on another server.

Something like: Pull everything from PullOnlyRepo to Server1 (we will call this origin, maybe?) Click "Disable branch" for ReivewRepo with the name of the JistChanges branch on Server2.

Right now git config -l is showing:

remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.url=<URL for Server1> remote.origin.pushurl=no_push (this shouldn't matter since it is a pull only repo) branch.production.remote=origin branch.production.merge=refs/heads/production remote.review.url=<URL for Server2> remote.review.fetch=+refs/heads/*:refs/remotes/review/* 

git pull does what I want (selecting changes from the right place on Server1 and merging them with my tree).

However, git push does not work. To achieve what I want, I need to do

 git push review hotfix:JistChanges 

Is there any way to do git pull do this without having to add extra stuff?

There are several questions that are already set so that your local branch clicks on remote access with a different branch name. However, they also change upstream and where the thrust comes from.

+6
source share
2 answers

You can install the upstream branch for hotfix :

 git config push.default upstream git config push.default review git branch --set-upstream hotfix review/JistChanges 

See “ How to make an existing git tracking branch a remote branch? ” See “ What is the result of git push origin ? ” In the default push policy (coming soon will be “ simple ”)

Running git1.8.0:

 git branch -u review/JistChanges hotfix 

OP jistanidiot reports achieved the same result:

 git remote set-url --push origin git config remote.origin.push refs/heads/hotfix:JistChanges 
+3
source

Ok VonC's answer gave me the right way. Here is what I did:

 git remote set-url --push origin <review repo URL> git config remote.origin.push refs/heads/hotfix:JistChanges 

The only problem is that now everything is being pushed to the review repository. This is normal, since 90% of the work will be in this thread. The other 10% I can just do git push other, where is another repo of the same name with the correct push configuration.

+1
source

Source: https://habr.com/ru/post/928065/


All Articles