0

I currently have a public github repository called bfs_assignment which I set up using following commands:

git config --global user.name <my name>
git config --global user.email <my email>
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git init
git status
git remote add origin <SSH of bfs_assignment>
git push origin master

Now I have created a new repository called from_aditya where I want to push the same changes. How to make it such that if I click on commit and push on my project, the changes are pushed to both the repositories.

Kindly comment if you need more information.

Aditya Dixit
  • 255
  • 2
  • 12
  • 1
    Does this answer your question? [Able to push to all git remotes with the one command?](https://stackoverflow.com/questions/5785549/able-to-push-to-all-git-remotes-with-the-one-command) – Amadan Apr 05 '22 at 07:51
  • I am using android studio where I have a flutter project. Where to type those commands given in the link. – Aditya Dixit Apr 05 '22 at 08:23
  • And how to connect `from_aditya` to my project? – Aditya Dixit Apr 05 '22 at 08:24
  • 1
    Your question is not tagged [tag:android-studio], and I have no knowledge about it. Where did you type the commands in your question? Same place. The link describes how to create a [remote](https://stackoverflow.com/questions/20889346/what-does-git-remote-mean) with multiple URLs. Pushing to such a remote would push to every associated URL. You can add an URL to your current remote (`bfs_assignment`) or you could make a new one (e.g. `all`), as described in your link. – Amadan Apr 05 '22 at 08:32
  • @Amadan, I am not able to understand. Should I repeat those given commands in question with `from_aditya` repository's SSH? – Aditya Dixit Apr 05 '22 at 08:50
  • 2
    You are currently using the remote `origin` (the default remote) with both push and fetch URL set to the address of your `bfs_assignment` repository. You can either add another push URL to `origin`, so that `git push` pushes to both, or you can make a new remote (e.g. `all`) with both URLs, so that when you `git push` you push just to `bfs_assignment` but when you `git push all`, you push to both repositories. For the second one, follow [Aristotle's answer](https://stackoverflow.com/a/5785618/240443); for the first one, just `git remote set-url --add origin `. – Amadan Apr 05 '22 at 08:59

0 Answers0