An open API service indexing awesome lists of open source software.

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

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