Let's start with 2 machines. The first one, "remote", is where you want to store the code and could be where other users will also pull copy of the code from. The second one, "local", is the machine where you want to check out the code and make your edits.
On "remote" we want to store the repository in /usr/local/src:
cd /usr/local/src
git --bare init
On "local" we want to work on the code in ~/workspace and we already have some files to populate the repository with so we first create a local git repository:
cd ~/workspace
git init
git add .
git status
git commit
Now let's push this code to the remote server:
git push ssh://@/usr/local/src
Done! Now we have both servers with the files. Files can be edited locally, commit locally and periodically synced/pushed to the remote server.
Now, on another computer, we want to "check out" the source code to work on it:
mkdir ~/workspace
cd ~/workspace
git clone ssh://@/usr/local/src
Some things to make it easier to work with:
1. Use ssh keys so that you don't have to put in your password each time you push to the remote host.
This was incredibly helpful. It is short and to the point and it works. Thanks so much!
ReplyDeleteThanks man! You conveyed the needed ideas and information without making it too overly specific and therefore confusing.
ReplyDeleteThank you for this tutorial.
ReplyDeleteI filled one pair parameter, it looks better...
git push ssh://user@host/usr/local/src
-------
git clone ssh://user@host/usr/local/src
Thanks buddy It works.
ReplyDelete