December 9, 2010

Git Get Started

Getting Started
Let's say you have a development project in the directory devproject. Let's start using Git to manage this project.
First off install Git. In Debian and Ubuntu we just need to do "aptitude install git"
cd devproject
git init
git add .
git commit -m "My first commit"
At this point you have all the benefits of a local version control system but no one can see your work. To make it available to other people we'll need to install a remote repository on your server. At home, I only allow people to access my code through SSH so that's the method I am going to talk about here.
ssh alex
mkdir -p /var/git/devproject.git
cd /var/git/devproject.git
git --bare init
exit
Your remote Git server is now configured so let's set up our local repository to talk to the remote repository
cd devproject
git remote add origin ssh://alex/var/git/devproject.git
We can now push our changes to that repository:
git push origin master
 
git clone: clone from a remote a new local repository
git fetch: update the local "remote" directory
git pull: = git fetch + git merge

No comments:

Post a Comment