
Git switch branch commandline update#
The sync command will fetch from upstream and update local branches AND if it determines a branch is merged and its upstream branch was deleted, then it will be deleted automatically. One of my favorite commands to clean-up my branches does not come with git itself, but is bundled with the GitHub Hub CLI. Thankfully there is a -dry-run mode so you can preview what would happen if you were to run the command for real. The prune command will help you identify those and remove them. Sometimes you have branches locally that are no longer tracked in GitHub or wherever. The following command will list out branches that have been already merged into the main branch (excluding the main branch itself) and then delete those locally git branch -merged main | grep -v "main" | xargs -n 1 git branch -d Delete Branchĭepending on the type of branch you want to delete there are several ways to do it. You can find installation instructions from their README.md.
Git switch branch commandline install#
NOTE: You'll need to install fzf for this alias to work. alias cb = 'git branch -sort=-committerdate | fzf -header Checkout | xargs git checkout' I also have a ~/.zshrc alias to list out my branches sorted by commit date and pipe those to fzf so that I can choose from a list the branch I'd like to checkout.

then develop branch appear in git server.

I did this: git commit -m '.' git push -u origin develop. this resolved with commit and push the develop branch.

Working on the command line with git can be a bit overwhelming, so I'm starting a series of git cheatsheet posts for various areas.
