Beginning Git Cheat Sheet

Filed in Web DevelopmentTags: Git, Oenology, Themes, WordPress

Since Theme developers don't (at least, not yet) have SVN-commit access for the WordPress Theme Repository, I decided to host Oenology on GitHub. Git is an entirely different beast from Subversion, so it took me a bit to figure out exactly how to use it.

So, for the most part, this post is my own personal cheat sheet, though perhaps someone else new to Git might also find it helpful.

Initial Setup

Generate SSH Keypair:

ssh-keygen -t rsa -C ""

Setup local system's global Git username and password:

git config --global "User Name"
git config --global

Setting Up a Local Repository

One major difference between SVN and Git that I quickly discovered is that SVN defaults to setting up subdirectories for the working copy (/trunk) and previously tagged versions (/tags), but Git does not. So, whereas with SVN, my local repository checkout (i.e. the directory tracked by SVN) was simply a directory called /oenology, with Git, it made more sense for me to create my own subdirectories: /master for the working copy and /tags for tagged versions, and then do my Git checkout in /oenology/master.

Change path to working directory:

cd ~/<path>/oenology/master

Initialize local directory as a Git repository:

git init

Checkout the remote repository:

git remote add origin<username>/<repository>.git

Working With Git Repositories

Add (stage) all files in the local directory to the repository:

git add .

Commit (snapshot) all file changes in the local directory:

git commit -m "Commit Message"

Push all snapshots to the remote repository:

git push origin master

Working With Tags

Tag the current snapshot:

git tag -a "Version Number"

Push all tags to the remote repository:

git push origin --tags

Delete a tag:

git tag -d "v12345"
git push origin :refs/tags/v12345

Working With Branches

List Branches:

git branch

Create a Branch:

git branch {branch}

Switch to a Branch:

git checkout {branch}

Push a Branch:

git push origin {branch}

Merge a Branch:

git merge {branch}

Delete a Branch:

git delete -d {branch} // only deletes the branch if all changes are merged
git delete -D {branch} // deletes branch, regardless of merge state

For More Information

For more detailed help, refer to GitHub Help, and to the Git Reference.

Twitter Updates for 2011-01-23

Filed in Lifestream

Twitter Updates for 2011-01-22

Filed in Lifestream

Twitter Updates for 2011-01-21

Filed in Lifestream

Twitter Updates for 2011-01-20

Filed in Lifestream

Twitter Updates for 2011-01-19

Filed in Lifestream

Twitter Updates for 2011-01-17

Filed in Lifestream

Twitter Updates for 2011-01-16

Filed in Lifestream
  • I'm not sure that was "indisputable visual evidence" that the elbow was on the ground. Looked like it brushed the top of the grass blades. #
  • It's a good thing I don't really care who wins this game. If I were a Ravens fan, I'd be ticked. They won't get any breaks from the refs. #
  • Yeah, Flacco is a *great* playoff quarterback. So much for the "Flacco just wins playoff games" meme. He's single-handedly losing this one. #
  • @Skitzzo I believe the exact words (to AZ Tea Party leader) were, "Trent Humphries, you’re dead!" That's not rhetoric; that's a death thread in reply to Skitzzo #
  • @Skitzzo *threat, not thread in reply to Skitzzo #
  • That was the worst holding call in the history of holding calls. #
  • @Skitzzo I totally agree with your point; was trying to reinforce it, but ran out of characters. πŸ™‚ in reply to Skitzzo #
  • Best pass I've ever seen Flacco throw & All-Pro Boldin lets it bounce off his chest in the end zone. The Ravens are trying to lose this one #
  • Plain-as-day holding call on Pittsburgh, and it gets called on Baltimore. Why even watch this crap? #
  • In which @lizardoid Charles Johnson gets pwned by @gatewaypundit Jim Hoft #
  • @Skitzzo take a look at my last Tweet, to see the hypocrisy of the left (and the media). in reply to Skitzzo #
  • @johnkolbert they're looking pretty impressive right now! in reply to johnkolbert #
  • @Pat1McAfee @laurawvu that's the worst review of Black Swan that I've heard yet. in reply to Pat1McAfee #

Twitter Updates for 2011-01-15

Filed in Lifestream

Twitter Updates for 2011-01-14

Filed in Lifestream