git grep "regex"
git branch -a
git branch -r
make sure you don't use origin
git fetch
git checkout branchName
first create a branch
git checkout -b <branchName>
Create a new branch from an existing branch
git checkout origin/branchName -b newBranchName
Then push your new branch to the repo
git push origin <branchName>
AKA Recover a deleted branch
git checkout -b <branch> <sha>
git reset --hard
Resets index to former commit; replace 56e05fced
with your commit code. You can use git log to get commit code
git reset 56e05fced
git checkout HEAD -- /somePath/file.txt
git checkout -- <file>
git checkout origin/branchName -- fileName.txt
git reset --hard HEAD~1
git reset --soft HEAD~1
git clean -f
git clean -f -d
git clean -fxd {dir_path}
git commit /folderToCommit -m 'commit msg'
git branch -a
git branch -r
git branch --contains <commit>
git log --pretty=format:"%h - %cr (%an) %s" --graph
git fetch
git merge origin/master
a shortcut to this is. They are both the same
git pull origin master
or, if it's a busy repo.
git pull --rebase <remote name> <branch name>
git diff --name-only --diff-filter=U
grep -lr '<<<<<<<' .
git mergetool -t opendiff
git pull -s recursive -X theirs origin ra
git log -m -1 --name-only
git diff --name-status master..branchName > changelog.txt
Get the SHA of the last commit on the branch.
git checkout -b newbranchname 56e05fced
git stash save "My changes."
git stash list
git stash apply stash@{1}
git push origin --delete <branchName>
git branch -d <branchName>
git cherry -v develop mybranch
This reverts the commit with a new commit.
First get the commit sha.
git revert -m 1 <commit-hash>
git commit -m "Reverting the last commit which messed the repo."
git push -u origin master
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \;
Save the results to a file.
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \; > gitreport.txt
run git fetch -p
this removes the remote references.
run git branch -vv
then run the following script
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
keywords: prune