Skip to content

Instantly share code, notes, and snippets.

@zhaocnus
Last active January 24, 2018 07:56
Show Gist options
  • Save zhaocnus/0d6e019483bd891d8fc152aebeeb3f54 to your computer and use it in GitHub Desktop.
Save zhaocnus/0d6e019483bd891d8fc152aebeeb3f54 to your computer and use it in GitHub Desktop.
# create local branch (shorthand)
git checkout -b <branch_name>
# create local branch
git branch <branch_name>
git checkout <branch_name>
# and then start hacking and commit
# push branch to remote
git push -u origin <branch_name>
# merge branch to master
git checkout master
git merge <branch_name>
git push -u origin master
# delete local branch
git branch -d <branch_name>
# delete remote branch
git push origin --delete <branch_name>
# print for timesheet
# http://stackoverflow.com/a/1441062/2259286
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
# Delete commits from a local and remote.
# https://stackoverflow.com/a/1338744
git reset --hard HEAD~1
OR
git reset --hard <sha1-commit-id>
AND THEN
git push origin HEAD --force
# ...
git config user.name zhaocnus
git config user.email zhaocnus@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment