Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can my friend use my local git repository as his remote repository?

Tags:

git

I have a local git repository on my computer. Is that possible my friend set his upstream to my local repository on my computer and my local repository becomes his remote repository? So he will be able to get the latest changes from my local repository and push to my local repository. (I don't want to use tools like github or gitlab or ...)

like image 403
Mohammad Taherian Avatar asked Nov 01 '25 23:11

Mohammad Taherian


1 Answers

The short answer: you can.

The long answer: you need to do a little bit more than just letting your friend add your local repo as his remote. The reason is that you always want to use a bare repo for multiple users to interact with. See this, and this for more detailed explanations.

Suppose your local repo is located under ~/projects/my-working-repo, you want to do this:

cd ~/projects
mkdir public-repo
cd public-repo
git init --bare
cd ../my-working-repo
git remote add origin $HOME/projects/public-repo
git push origin --all

Now all the history in your local repo are in public-repo. You and your friend can push commits to, and pull from public-repo. my-working-repo will remain your own working area.

like image 73
jingx Avatar answered Nov 03 '25 13:11

jingx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!