Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT workflow w/ multiple workstations and a centralize server

Tags:

git

Ok, a few things I'm not quite sure about.

For starters:

  • I have a "bare" repo on a VPS in a remote DC.
  • I have a workstation at work that I also code on.
  • I have a workstation at home that I also code on.

1 - When I set up my initial repo on one of my workstation (i think Git calls this the master), should I check out and work from a different directory? Like subversion.

2 - When I want to work on the code at work, I'm confused, how do I go about making commits to the LOCAL repo on my work desktop and then at the end of the day, push my changes to the "bare" repo on my VPS so that I can pull the updates to my home desktop.

I tried using clone but every push I make from my home desktop ended up w/ me pushing the changes back to the remote repo.

like image 428
sdot257 Avatar asked Feb 18 '26 08:02

sdot257


1 Answers

1 - master is git's default name for the main branch of a repository. It does not refer to the entire repository, but to that one line of development. You don't need a separate working directory - the general idea of local git development is to work in the directory, commit changes to the repository, then push them upstream as necessary.

2 - You should have a remote in both your home and work repos pointed at the bare VPS repo. If you created your repo by cloning the VPS repo, it will be 'origin'. Pushing to and pulling from origin are the defaults, so this is why your pushes are going there. This is the designed behavior - there's a good chance that when you clone a repo, it's the one you want to get updates from and push your changes back to.

I would suggest having both home and work treat the VPS repo as origin. You can then push to and pull from it on each computer when necessary, simply using git push and git pull. If one of your repos isn't already set up this way, you could either reclone the VPS repo to do it automatically, or use

git remote add origin <url-of-VPS-repo>
git config branch.master.remote origin
git config branch.master.merge = refs/heads/master

The last two lines let git know that you would like your master branch to be associated with the master branch on the origin remote (your VPS).

like image 66
Cascabel Avatar answered Feb 20 '26 21:02

Cascabel



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!