Rudi Engelbrecht's Blog

Just another WordPress.com site

Git Recipes – Initialising local and remote

leave a comment »

Understanding git and using it as a distributed version control system is easy once you manage to ‘unlearn’ the the concept of a server repository used by SVN and CVS.

I usually start a new project by working on my local machine and then after a while I would like to continue the project on another machine.

Starting a Git Project

mkdir project
cd project
git init

Create and edit files as needed.

git add .
git commit -m “initial commit”

The local files are now commited to the local master branch.

Once you are ready to share the files / project on another machine, create a git project on your remote machine, or use github / repositoryhosting.com / projectlocker.com to provide a remote repository.

The next few steps will link and push the local master branch to the remote master branch hosted at projectrepo.com.

git remote add origin git@projectrepo.com:project.git
git push origin master

The local master branch is now pushed to the remote master branch.

You can continue working on the local repository, create local branches, merge them into your local master branch, and once you feel the remote master branch needs to be updated, then you can use the line below.

git push origin master

Hope this helps 😉

Advertisements

Written by Rudi Engelbrecht

January 15, 2011 at 10:53 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: