Skip to content

Latest commit

 

History

History
61 lines (50 loc) · 1.76 KB

git.md

File metadata and controls

61 lines (50 loc) · 1.76 KB

Git

Convert a submodule to regular files

git rm --cached $submodule # Delete references to submodule HEAD
rm -rf $submodule/.git* # Remove submodule .git references to prevent confusion from main repo 
git add $submodule # Add the leftover files from the submodule to the main repo 
vim .gitmodules # Remove reference to the submodule 
git add .gitmodules  
git commit -m "Converting submodule $submodule to regular files" # Commit the new regular files!

# https://ben.lobaugh.net/blog/202883/bash-script-to-automatically-convert-git-submodules-to-regular-files

Show lines of code committed to a repository for the day

git log --since="6am" --author="mmcachran" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

Git stats for all branches

git shortlog -s -n --all

Log for function name/lines in a file:

git log -L:<function>:<file>
git log -L150,+22:<file>

Show all branches merged into a specific branch

git branch -r --merged | grep origin | grep -v '>' | grep -v 'master' | xargs -L1

Show global git config

git config --global -l 

Ignore case in global config

git config --global core.ignorecase false

Remove local branches that no longer have a remote

git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done

Reset-checkout.. checks out branch, removes untracked files, and re-inits submodules.

checkout-reset() {
	git checkout $1 && remove-untracked && git submodule update --init --recursive
}

Find lost files.

git fsck --lost-found