[advertisement]

Interested in putting your ad here?

Blog Entry

10th May 2010
Send to twitter Send to Facebook

Here's a post to remind me of simple Git procedures. Maybe other people with find this helpful. After using CVS for a decade, it's a bit hard to wrap my head around git, but I'm making that journey.

I'm using github as my repository.

START A NEW PROJECT

mkdir MYPROJECT
cd MYPROJECT
git init
touch README
git add README
git commit -m "first"
git remote add origin git@github.com:/GITHUB_USERNAME/MYPROJECT.git
git push origin master

A git repository URL looks something like this: git@github.com:/taskboy3000/Tester.git

WORK ON AN EXISTING PROJECT

git clone [GITPROJECTURL]

ADD FILES TO LOCAL REPOSITORY

git add [FILE]
git commit -m "My comment about the files I added"

You can also add all the files in your project at once:

git commit -a -m "All files, including tilde files, have been added"

UPDATE REMOTE MASTER WITH LOCAL SANDBOX

git commit -m "Final checkin"
git push origin master

UPDATE LOCAL SANDBOX WITH REMOTE MASTER

git fetch origin
git merge origin master

REVERT LOCAL SANDBOX TO REMOTE MASTER

git reset --hard

This will restore deleted files and overwrite uncommitted changes.

Also see the github book.

Very helpful
:: 6th May 2011 - 14:05
:: Jamie
Git was entirely baffling to me and this was the thing that got me able to actually start using it. Thanks for posting.

Blog archives

+ About this blog