DEV Community

Cover image for Git multi repository push at a time (git pushall)
Nurul Islam Rimon
Nurul Islam Rimon

Posted on

Git multi repository push at a time (git pushall)

**Step-by-Step Guide
Initialize the Local Repository: If you haven't already initialized a repository locally:

git init
Enter fullscreen mode Exit fullscreen mode

Add the First Remote Repository (example: nurul):

git remote add yourName repository-url
Enter fullscreen mode Exit fullscreen mode

Add the Second Remote Repository (example: expertsquad):

git remote add companyName repository-url
Enter fullscreen mode Exit fullscreen mode

Verify the Remotes: Check if both remotes are added correctly:

git remote -v
Enter fullscreen mode Exit fullscreen mode

You should see output like:

yourName https://github.com/your-username/repo-name.git (fetch)
yourName https://github.com/your-username/repo-name.git (push)
companyName https://github.com/company-username/repo-name.git (fetch)
companyName https://github.com/company-username/repo-name.git (push)

Push to Both Repositories Simultaneously: If you want to push changes to both repositories:

git push yourName main
Enter fullscreen mode Exit fullscreen mode
git push companyName main
Enter fullscreen mode Exit fullscreen mode

Automate Pushing to Both Remotes (Optional): Create a custom alias in Git to push to both remotes at once:

git config --global alias.pushall '!git push yourName && git push companyName'
Enter fullscreen mode Exit fullscreen mode

Now, you can use:

git pushall
Enter fullscreen mode Exit fullscreen mode

Notes:
Replace main with the branch name you're working on if it's different.
Ensure that both remotes are up-to-date with proper access rights (SSH keys or tokens if needed).
Use branches carefully if the repositories have different requirements.
Let me know if you need further clarification!

Top comments (1)

Collapse
 
jackfd120 profile image
PO RA N

Oh, That's millon doller concept.