Git is used broadly for now. Let’s look at interesting use case. Assume, we have the development machine and the live server. I’m going to hold the project in local git repo on development machine. From time to time it needs to deploy stable version to the live server as a release.
Just for demostration, I use 2 local directories /tmp/dev and /tmp/server:
Then I init new repo and add some test file in the release branch on the dev side:
git checkout -b release
git add test.txt
git commit -m “initial commit”
Now I create empty repo on the server side and checkout for server branch:
git checkout -b server
Next step is to configure and pushing prepared release to the server:
git remote add server file:////tmp/server
git push server release
Here we use local file URL. In real situation it needs SSH one, like ssh://login@host:port/path/to/project.
Last stage is to merge just pushed version from release branch to current one (server) on the server:
git merge release
At this point the new version is on the server side.
Usually, we host the repo of the project on github or bitbucket. Last one even allows to create private repo’s if you are not ready to share your code with the world yet. So, described above example should be treated rather as an exception then standard use case.