For a while now, I’ve had a gradually-expanding note with various git commands that I’ve been using as a cheat sheet for git tasks that I do not do often, but regularly enough to write them down.
I figure putting them here will not only make them (slightly) easier to get to every time, but may also help other folks out.
So here they are! Keep in mind that this is just a quick (and intentionally incomplete) cheat sheet – if you are learning git for the first time, you’re better off looking elsewhere (this is a good place to start).
Delete a file from the repo (opposite of ‘git add’):
git rm filename
revert a file to the current committed version
git checkout -- filename
cache credentials when using https (seconds):
git config credential.helper 'cache --timeout=300'
clear cached credentials:
git credential-cache exit
ignore changes to a versioned file:
git update-index --assume-unchanged <file>
stop ignoring those changes:
git update-index --no-assume-unchanged <file>
change commit message of last commit:
git commit --amend -m "New commit message"
pull a new branch from origin and track it
git checkout --track -b origin/daves_branch
push a new local branch to origin:
git push -u origin branch-name
create a new branch:
git checkout -b new_branch
merge changes from branch hotfix into master:
git checkout master git merge hotfix
delete the local branch:
git branch -d hotfix
track a remote branch:
git branch --set-upstream krystof_plots origin/krystof_plots
create a tag and push it to origin:
git tag -a v1.4 -m 'my version 1.4' git push origin --tags
git pull --tags
find out what tag you’re on:
git describe --tags
Add upstream remote:
git remote add upstream email@example.com:krystofl/krystof-utils.git
sync a fork (https://help.github.com/articles/syncing-a-fork):
git fetch upstream git checkout master git merge upstream/master
Reset a fork to whatever is on upstream:
git fetch upstream git checkout master git reset --hard upstream/master git push origin master --force
Add a git repo as a submodule:
git submodule add https://github.com/krystofl/krystof-utils.git
To make the submodule track a the master branch:
open .gitmodules, and add a line to the submodule info:
branch = master
I made it out to Catalina once again for a camping trip; here are a few photos.
Bryce Canyon National Park is like walking on another world. Really, though, it is beyond the power of words or photos to do a place justice, so do yourself a favor and go visit it.
You may enjoy these photos as a teaser.
When hiking in, eventually you reach a point where there are no more trails – you need to find your own way through the rock formations and canyons. That makes hiking there all the more enjoyable – it rekindles a sense of adventure and discovery.
Here are some photos.
Coral Pink Sand Dunes State Park is a State Park in Southwestern Utah. I found it a very unique place – a valley filled with sand, but on either side there is vegetation, even trees. The color of the sands is very striking; the photos can’t quite do it justice.
I was up in Utah for a weekend recently, in the general vicinity of Salt Lake City. Here are some photos.
Montaña de Oro State Park is on the Pacific coast, not far from Morro Bay. I made it up there for a weekend recently – here are some photos.
Once again, I hiked up in the vicinity of Islip Saddle, and, once again, here are some photos. Hope you like ’em.
To complete my Zion trilogy, here are some photos from The Narrows, probably the most popular hike in the park. It is popular for good reason – it is fantastic. On the flip side, of course, it gets crowded, particularly near the beginning. You can see that in the last photo.