How do you create a remote Git branch?

First, you create your branch locally: git checkout -b <branch-name> # Create a new branch and check it out The remote branch is automatically created when you push it to the remote server. So when you feel ready for it, you can do: git push <remote-name> <branch-name> Where <remote-name> is typically origin, the name which … Read more

Deleting a badly named git branch

Did you try git branch -D — –track ? the “–” is usually the convention for “what follows is not an option, whatever its name” From “The Art of Unix Programming”, section “Command-Line Options”: It is also conventional to recognize a double hyphen as a signal to stop option interpretation and treat all following arguments … Read more

Why does git perform fast-forward merges by default?

Fast-forward merging makes sense for short-lived branches, but in a more complex history, non-fast-forward merging may make the history easier to understand, and make it easier to revert a group of commits. Warning: Non-fast-forwarding has potential side effects as well. Please review https://sandofsky.com/blog/git-workflow.html, avoid the ‘no-ff’ with its “checkpoint commits” that break bisect or blame, … Read more

How to fetch all Git branches

TL;DR answer git branch -r | grep -v ‘\->’ | sed “s,\x1B\[[0-9;]*[a-zA-Z],,g” | while read remote; do git branch –track “${remote#origin/}” “$remote”; done git fetch –all git pull –all (It seems that pull fetches all branches from all remotes, but I always fetch first just to be sure.) Run the first command only if there … Read more