git reset --hard @{u}
git checkout master
git branch --merged
git remote prune origin
Deletes all stale remote-tracking branches under . These stale branches have already been removed from the remote repository referenced by , but are still locally available in "remotes/".
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}'
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | %{git branch -d $_}
The command above replaces xargs
with PowerShell syntax for a Foreach loop. I run posh-git behind PowerShell and was having some issues getting xargs
to work right. First had to using -I
flag and wrap the input in quotes to get proper line replacement: xargs -I% git branch -d '%'
. But then it was still not executing right.
git add -p <file>
https://git-scm.com/docs/git-add#git-add--p
stash file1.js and file2.js
git stash push -m "Description" ./file1.js ./file2.js
select parts of diff to stage from all files
git stash push -p -m "Description"
select parts of diff to stage from file1.js and file2.js
git stash push -p -m "Description" ./file1.js ./file2.js
(q can quit at any point keeping all changes already chosen for stash)
git fetch origin <branch>:<branch>
For example:
git fetch origin dev:dev
(Stolen from GitHub manual merge of PR instructions)
git checkout -b <new branch name> main
git pull [email protected]:<external repo>.git <existing branch>