Git Workflow: Without a server

2019-01-30 13:53发布

git is supposed to be a decentralized system, but all the tutorials and best practice workflows I have found on google suggest using a server (usually github, or else set up your own)

I am using git for small personal projects (2-3 people), where can I find a best practice workflow for syncing changes directly between the team members machines. Alternatively, what are some compelling arguments for why I should avoid this and instead set up a 'central' server?

Thanks,
Ben

7条回答
神经病院院长
2楼-- · 2019-01-30 14:39

What you need to do first, is to think through what kind of workflow you have already and configure git to work with that. Once you have something up and running, you can fine tune it. There is no need to setup a separate computer as a server. If you are accustomed to have a central repository all you need to do is to create a bare repository that everyone pushes to. Why not on the local network?

Central repo:

mkdir foo.git
cd foo.git
git init --bare

Your repo:

mkdir foo
cd foo
git init
// add files
git add .
git commit -m "Initial commit"
git remote add origin //path/to/central/repo/foo.git
git push origin master

Other repos:

git clone //path/to/central/repo/foo.git

Now anyone can push and pull directly from master branch. This should be enough to get you started.

查看更多
登录 后发表回答