cover-img

Share files between multiple repositories: Advanced Git

12 February, 2024

18

18

0


GitHub is a powerful platform for version control and collaboration, widely used by developers around the world. While it's straightforward to work within a single repository, there are times when you may need to share files between repositories. Fortunately, GitHub offers several methods to achieve this. In this guide, we'll explore one such method: sharing a single file from one repository to another.

Step 1: Firstly, let's clone a repository to our local machine and create a file.

git clone [github_repo](link)

touch xyz.txt

Step 2: Commit and push the changes to the repository on GitHub

git status

git add (file-name)
git commit -m "(message regarding the changes)"

git push origin main

This is an important part to understand, when we use git push command, we declare the destination (the repository we want to make changes to) and the branch of that repository (By default it is set to main)

Step 3: Look for the destinations assigned to the repositories

git remote -v

Step 4: Add another destination linked to another repository

git remote add backup [repository_link](link)

Step 5: Check for the destinations again

git remote -v

Step 6: Now you can push the changes to another repository while being in other

git push backup main

The same changes can now be pushed to second repository from one repository.

Sharing files between multiple repositories is a useful feature that can streamline collaboration and organization. Following the steps outlined in this guide, you can easily share files between repositories and ensure that your projects are well-structured and accessible to your team members.

git

github

beginner

devops

devopsdigest

18

18

0

git

github

beginner

devops

devopsdigest

Sourav Dhiman
DevOps | Golang | Kubernetes | Docker | GCP | CI/CD | Shell Scripting | Terraform | ArgoCD | Linux | Building in Public 🏡

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.