Feb 01 2016 0

Git(hub) goodies

Here are some of git commands I have found useful working with Git(Hub) repositories from the command line.

Make current directory into a github repo

git init

Push local repo to remote (github) repo

git init
git add .
git commit -m "Initial commit"
git remote add origin <remote repository url>
git remote -v
git push origin master

For a GitHub repository the <remote repository url> has the following format https://github.com/<github user>/<repository name>.git View history (also lists hash per commit)

git log --pretty=oneline

Restoring old version

git checkout <hash> -- <filename>

Review changes between current file and most recent committed

git diff HEAD -- <filename>

or

git diff <filename>

See changes between current file and a history version

git diff <hash> -- <filename>

See changes between two history versions

git diff <hash1>  <hash2> -- <filename>

All changes since last commit

git diff

Revert local changes (including staged changes)

git fetch origin
git reset --hard origin/master

Unstage a file

git reset HEAD <file>

Previous post
Apps for January 2016 In January I have bought a number of applications for either my iOS devices or my Mac. I am planning to make a monthly post listed the most notable
Next post
Adding Disqus comment counts to Entries template On the entries page I wanted to be able to show the number of comments each post has. Disqus provides functionality for this purpose.
This blog is powered by Blot