My Git Knowledge

The full extent of my Git knowledge. Don't worry this won't take long.

Git, yeah it's cool and not just another trend.

If you haven't used Git for your version control yet, you should. I resisted for a while thinking that nothing is wrong with Subversion. But after trying Git because of Sparks, I now see that its not just yet another stupid programming trend. Anyhow, that's my opinion, but if you want to use Git, these commands will get you up and running.

My Git Cheat Sheet

All the following commands are run after you cd into the directory your build is in.
In my case

[bash]
cd /Applications/mamp/htdocs/name_of_project

build a git repo in a directory initializes the project as a git repo

[bash]
git init

Add a file or folder

[bash]
git add [yourfilename]

Commit all changed files in the directory

[bash]
git commit -a -m "your commit message"

Add your remote origin remote origin is where the files go on push example: github

[bash]
git remote add origin git@github.com:[username]/[Repo-Name].git

Push commits to the remote repo

[bash]
git push -u origin master

Add a version number

[bash]
git tag 1.0

Push your tag to the remote repository

[bash]
git push --tags

Thats it for basic usage, if you're like me that will keep you going for the first few days. But then i got a pull request on one of my repos so i had to figure that out then.

Merging Pull Requests

[bash]
git checkout master
git remote add [username] git://github.com/[username]/jobs.git
git fetch [username]
git merge [commit #]
git push origin master

Git clients

I will probably get a Git client here before too long but for now im doing ok with the terminal. I hear good things about Git Tower and may purchase it.

Logo
 
 
profile for David Morrow at Stack Overflow, Q&A for professional and enthusiast programmers