As long as you use it yourself in a one man project, a distributed repository is almost the same as CVS and SVN. You check code out, make modifications and commit. The major difference is that you then "push" your commits to another repository, usually a remote server.
Create a local repository
To get started, after installing GIT, you can create a repository with the "init" command.cd /path/to/repository git init
Make modifications
Just like CVS and SVN, you can add/modify/delete files and commit them.git add readme.txt git commit -a -m "added readme text"Note that this commit is stored locally, it is not committed to a central server.
Copy a repository
You can create a copy of a local repository with the "clone" command. This way you can locally make a branch.cd /path/to/workspace git clone /path/to/repository
Shareable repository
To create a sort of "central" repository like CVS or SVN, you can create a shareable repository with the "init" command. Do this on your server.cd /path/to/repository git init --bare --shared
Checkout with SSH
I use SSH to "checkout" from the remote repository, do this on your client.cd /path/to/workspace git clone ssh://myserver/path/to/repositoryThis makes a copy of the remote repository to my local workspace. Here I can make modifications and commit them. GIT will store your commit locally until you "push" this to the central repository.
git add readme.txt git commit -a -m "added readme text" git push origin masterThis last command will update the remote repository with your commits.
See also
- I found this excellent article on GIT on stackoverflow: http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide
- Git for SVN users: http://git.or.cz/course/svn.html
No comments:
Post a Comment