My Git Workflow

0joe12th Feb 2009Development, ,

I was never a fan of Subversion because every time I tried using it, I always managed to corrupt the repository. Also having .svn files everywhere really annoyed me.

On the other hand, I have yet to ruin a Git repository. It’s incredibly easy to use and everything is stored in a top-level .git directory. It’s great and I’ve learned to use it constantly. Here’s my average work flow with a project:

Initializing

I’ll start a project like usual and begin writing some code. Once I’ve completed a good bit, I’ll initialize the git repository:

cd /project/root
git-init

Enabling Remote Repository Access

For portability and data-backup reasons, I like to store the git repo on an external server. To create the remote repository, I do:

cd /project
git clone --bare project project.git
scp -r project.git jtopjian@remote:/path/to/git/repo/

Then in my local repository, I’ll add an alias to the remote project:

cd /project/root
git remote add origin ssh://jtopjian@remote/path/to/git/repo/project.git

Note the lack of a colon (:) in the last command. The ssh string must be the absolute path to the git repo.

By choosing an alias of origin, I’m now able to push updates to the remote repository by only typing:

git push

If I were to call the remote repository something different, such as

git remote add remotegit ssh://jtopjian@remote/path/to/git/project.git

Then I would have to use:

git push remotegit

Conclusion

Git is a great version control system that I’ve found extremely easy to use. I highly recommend trying it out.

GitCasts has a series of free Git Screencasts and the Git Internals PDF is also a great read.

No Comments Comments Feed

Add a Comment