# Search for a word in log diff
git log -S"def email_required"
# display branches in activity order
git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname)' refs/heads refs/remotes
# checkout previous branch
git checkout -
git checkout @{-1}
# get rid of the latest changes and restore to the sha
git checkout sha1
# undo latest pull
git reset HEAD@{1}
git checkout .
# discard conflicting changes in a dir (after merge)
git co --theirs dir/ # discard their changes
git co --ours dir/ # discard our changes
# stash
git stash save "name of the stash"
git stash apply
git stash help
# checkout a new branch from origin
git checkout -b new origin/new
# tags
git tag "tag-name"
git push --tags
# bisect for debugging
git bisect start
git bisect bad
git co 32c4bf6 # (known good sha)
git bisect good
# create a patch
git format-patch -1 sha1
# and to apply it
git am 0001-commit-name.patch
# ignore a committed file
# add the file to .gitignore
git rm --cache your_file
# ignore the repo
git update-index --assume-unchanged .ruby-version
# delete a remote branch
git push origin --delete branch_name
# rename a branch
git branch -m old_name new_name
# all your commits on any branch in the last x months
git log --pretty=format:"%ad:%h:%B" --date=short --reverse --all --author=erik --since=1.day.ago
# count the lines of code of your app
git ls-files app/ | xargs wc -l
# undo a merge that was already pushed:
git revert -m 1 merge_hash
#
#
Here great post on git tips
.gitignore_global (add .rbenv-gemsets)Here's my git config
Git style guide
Best practices
No comments:
Post a Comment