git add .
git stash -u
- To see last two commits:
git rebase -i HEAD~2
- Delete the last commit with
dd
on the second line - Save the file with
:wq
- Force the changes to GitHub
git push -f origin master
- replace master with branch name if needed
git rm --cached "*.DS_Store"
git commit -m "Remove .DS_Store files"
- And make sure to add .DS_Store to the .gitignore file
Add the code below to .bash_profile or .bashrc. Make sure to then restart the terminal for changes to take effect.
function lazygit() {
git add .
git commit -m "$1"
git push origin master
}
Can commit all changes and push to master branch like this: lazygit "test push"
- Edit message:
git commit --amend -m "Better Message"
- Force push to GitHub:
git push -f
- Stage changed files:
git add .
- Amend last commit w/o changing message:
git commit --amend --no-edit
- Force push to GitHub:
git push -f
- Enter:
git log --oneline
- For tags, branches, and some ASCII art use:
git log --oneline --graph --decorate
Add the code below to ~/.gitconfig
[color "status"]
added = blue bold
changed = cyan bold
untracked = red
The specific colors can be customized as desired. More options here: http://misc.flogisoft.com/bash/tip_colors_and_formatting
Download instructions are here: https://github.com/tj/git-extras/blob/master/Installation.md
For example, with a Mac and Homebrew you can run: brew install git-extras
- See commit count:
git count
- Output repo summary:
git summary
- Display effort stats:
git effort
More commands here: https://github.com/tj/git-extras/blob/master/Commands.md
git config --list
- user.name
- user.email
- etc.
git ls-files | grep -vE "(png|jpg|ico|gif)" | xargs wc -l
Media files (images, icons, and gifs) will be excluded in the count