I use git mainly to backup my code, my idea is to backup my code twice in two different hostings, Github and Bitbucket for example. Thus, instead of copying code back and forth between the two repos, I put the .git
of each on the same directory so when I git add *
git commit -m ""
and git push
things happen simultaneously.
If not possible, is there any good solution?
Asked
Active
Viewed 290 times
0

Taoufiq Jmari
- 35
- 6
-
2You have an incorrect mental model of how Git and remote repositories work. You can add any number of remotes to the same local repository. – Felix Kling Mar 09 '20 at 11:56
1 Answers
1
Perhaps you should ask a different question. But if I understood correctly: Yes, you can have multiple remotes you push to.
pull/push from multiple remote locations
https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
If properly configured you would just push to both with 1 command:
git push
Or a simple example:
- add additional remotes for this repo via
git remote add <YOUR_REMOTE_NAME> ssh://
- list remotes with
git remote -v
- push to both
git push origin && git push my-new-remote
Perhaps you should read about git remotes a little.

trainoasis
- 6,419
- 12
- 51
- 82