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 "[email protected]"
Setup local system's global Git username and password:
git config --global user.name "User Name"git config --global user.email [email protected]
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 [email protected]:<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 mergedgit 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.
Beginning Git Cheat Sheet – http://www.chipbennett.net/2011/01/23/be… #wordpress
Beginning Git Cheat Sheet – http://www.chipbennett.net/2011/01/23/be… #wordpress
RT @chip_bennett: Beginning Git Cheat Sheet – http://www.chipbennett.net/2011/01/23/be… #wordpress
@chip_bennett Has your site been hacked? It’s making me fill a captcha to see: http://www.chipbennett.net/2011/01/23/be…
@chip_bennett Interested in the git article, but not “fill out a captcha” interested. :/
@devinsays are you trying to access via mobile?
@devinsays especially if you’re trying to access via mobile, it’s very likely my CDN. I have it set for fairly aggressive security.
@devinsays try again now? I just set security from High to Medium.
Ah, so that’s how you tag a version. Wish I known that earlier.