Skip to content

Instantly share code, notes, and snippets.

@feihong
Last active November 21, 2015 00:50
Show Gist options
  • Save feihong/b190e3ee35222ca9a92b to your computer and use it in GitHub Desktop.
Save feihong/b190e3ee35222ca9a92b to your computer and use it in GitHub Desktop.
Git cheatsheet

Undo last commit:

git reset --soft HEAD~1 

Download just the source code of a project:

curl -sL https://github.com/feihong/tutorial-boilerplate/archive/master.tar.gz | tar xz

Create new, empty repo, sync it to GitHub, and create the gh-pages branch:

USERNAME=feihong
REPONAME=repo-name
REPODESCRIPTION="repo description"

curl -u $USERNAME https://api.github.com/user/repos -d "{\"name\": \"$REPONAME\", \"description\": \"${REPODESCRIPTION}\"}"
git init
git remote add origin [email protected]:$USERNAME/$REPONAME.git
git remote -v
echo "$REPONAME" >> README.md
git add README.md
git commit -m "Initial commit"
git push -u origin master

cd /tmp
git clone [email protected]:$USERNAME/$REPONAME.git
cd $REPONAME
git checkout --orphan gh-pages
git rm -rf .
echo "Hello GitHub Pages!" > index.html
touch .nojekyll
git add .
git commit -a -m "Initial pages commit"
git push origin gh-pages

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment