• Git: Delete all local branches except master

    git doesn't provide the ability to delete all the local branches except one or more, but we can pipe together git branch, grep, and xargs git branch to delete all the local branches except the branch...

  • Git: Delete all remote branches except master

    git doesn't have a command to delete all the remote branches with exceptions. However, the task can be accomplished by setting some variables and piping git branch -r, grep, sed, and xargs git push.

  • Git: Deleting branches

    Local git branches can be deleted using the git branch command with the -d or -D option. Remote git branches can be deleted using the git push command with the --delete option or :.

  • Git: Overwrite with forced pull

    There is no single command to do a forced pull from the remote. However, using git fetch --all and git reset --hard origin/<branch>, we can overwrite the changes to the tracked files, effective...

  • Git: How to merge a specific commit

    You were working on a certain branch of a git repository, and you committed some changes to it. Then you realize, this particular commit should also go to another branch of the repository BUT you are...

  • Git not working after macOS update: invalid active developer path

    macOS updates do not update the Xcode Command-line Tools by default. Unless it is updated many command-line tools like git will fail to work. It can be updated using xcode-select --install.

  • Git: Remove untracked files

    git clean is the command for deleting untracked files and directories. By default it's operations are limited to only files, using the -d option, untracked directoires can also be removed from the re...