https://github.com/seanmisra/gittricks
Tricks to speed up git work flow
https://github.com/seanmisra/gittricks
Last synced: 3 months ago
JSON representation
Tricks to speed up git work flow
- Host: GitHub
- URL: https://github.com/seanmisra/gittricks
- Owner: seanmisra
- Created: 2017-04-26T21:51:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-07T16:59:46.000Z (almost 8 years ago)
- Last Synced: 2025-01-10T14:41:41.769Z (5 months ago)
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GitTricks
Stage all changes
git add .
Undo all changes
git stash -u
Delete last commit pushed to GitHub
- 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
Remove all .DS_Store files from Git repo
git rm --cached "*.DS_Store"
git commit -m "Remove .DS_Store files"
- And make sure to add .DS_Store to the .gitignore file
LazyGit: add, commit, push
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 last commit's message
- Edit message:
git commit --amend -m "Better Message"
- Force push to GitHub:
git push -f
Amend prior commit
- Stage changed files:
git add .
- Amend last commit w/o changing message:
git commit --amend --no-edit
- Force push to GitHub:
git push -f
Clean commit log
- Enter:
git log --oneline
- For tags, branches, and some ASCII art use:
git log --oneline --graph --decorate
Change git status colors
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
Git-Extras
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
View config settings
git config --list
- user.name
- user.email
- etc.
Count lines of code in a repo
git ls-files | grep -vE "(png|jpg|ico|gif)" | xargs wc -l
Media files (images, icons, and gifs) will be excluded in the count