- Clone new version of repo, on required branch.
git clone --branch <branch> --origin origin --progress -v <git repository A url>
- Remove origin to prevent accidentally pushing
git remote rm origin
- Strip everything from the repo, except required "directory"
git filter-branch --subdirectory-filter <directory> -- --all
- Clean redundant information
git reset --hard
git gc --aggressive
git prune
git clean -fd
- The files will now be at the root directory. Move into a subdir if required
mkdir new_sub_dir
git mv * new_sub_dir
git add .
git commit
- Now prepare recipient repository. Create a temporart remote connection to the stripped local repo
git remote add stripped-repo <stripped repository directory path>
- Pull files and history into repo
git pull stripped-repo master --allow-unrelated-histories
- Remove temporary remove from repo
git remote rm stripped-repo
- Push changes
git push
git branch -d branch_name
git branch -D branch_name
git push <remote_name> --delete <branch_name>
git push origin --delete feature/something
git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
git config --global alias.lbc = log --graph --simplify-by-decoration --pretty=format:'%d' --all
git config --global aliases.lbcc = log --graph --simplify-by-decoration --oneline --pretty=format:'%C(auto)%d %s' --branches
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches
git config --global alias.lbf = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches