How to set default push repository in Git?
default, git
Solution
In git the remotes are in the `[remote "<name>"]` sections. When you clone something, the initial remote is `origin`, so that's usually the one to use. The fetch URL is the `url` and the push URL is the `pushurl`. You also need a `fetch` line (or several lines) to bring over branch names.
Typically, then, you will see, in `.git/config`, something like:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://...
Change the url to `git://source` and add `pushurl = git://target` (you can do this with `git config` commands, or `git remote`, or just run `git config -e` to bring up your regular editor on the file).
Branches need to have an "upstream" set (in two parts, `remote` and `merge`) to cause them to "track" a "remote branch". Typically since the remote is named `origin` you set `branch.master.remote` to `origin` and `branch.master.merge` to `master`, for instance. (When you create a local branch based on a remote branch, in any even slightly modern version of git, it will set it up as "tracking" for you.)
Generally you should also configure `push.default` to something other than the git 1.x default value; `simple` is probably best for avoiding accidents.
Note that if you're used to Mercurial, `hg pull` is most similar to `git fetch`, not `git pull`; `hg pull -u` is somewhat closer to `git pull`, but I recommend training yourself to use `git fetch` instead of `git pull` (even if you're not used to Mercurial, actually :-) ). It also takes some adjusting to the different ways hg and git handle branches (hg has one single global name space for branches, and another single global one for bookmarks; git has per-remote "remote branch" name spaces, and local branches are more like hg local bookmarks.)
Problem
How can I make `git pull` from `git@source.com:...` repository and `git push` to `git@target.com:...` repository by default? In Mercurial I create `.hg/hgrc` with the following content: ``` [paths] default = ssh://hg@source.com/... default-push = ssh://hg@target.com/... ``` What is the way to set the same default behaviour in Git?