Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default push repository in Git?

Tags:

git

default

How can I make git pull from [email protected]:... repository and git push to [email protected]:... repository by default?

In Mercurial I create .hg/hgrc with the following content:

[paths]
default = ssh://[email protected]/...
default-push = ssh://[email protected]/...

What is the way to set the same default behaviour in Git?

like image 737
anatoly techtonik Avatar asked Dec 25 '22 16:12

anatoly techtonik


1 Answers

It's almost the same in git. Each repository has a .git/config file and there should be some thing like this in it:

[remote "origin"]
url = git://path/to/your/repo
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

You don't have to add those manually, there's quite a few commands that help you. A good start is the Git SCM Book.

To set the default fore one single branch you can simply type: git branch --set-upstream-to YOUR_REMOTE_NAME/YOUR_BRANCH_NAME(when using git >= 1.8.0)

like image 114
klaustopher Avatar answered Jan 10 '23 03:01

klaustopher