Git Delete Local Branch

You push the branch to GitHub, open a pull request, and later the branch gets merged and deleted through the GitHub web interface. How to create a local copy of a remote branch in Visual Studio – 116 Suppose you’ve cloned a project from a GitHub repo that contains multiple branches. Have you ever made a few commits on a branch, only to later realise that you should have been working on a topic branch (i. Here is when the checkout command will help you. 0 release/8. Check git reflog for the last commit of that "lost" branch, then create a new branch, which is basically just a pointer to a commit, with git branch branchname shorthash, e. if you are not familiar with this concept, please revisit the Git document site first. This video will demonstrate how to remove a GitHub repository from within Visual Studio. About half of my interactions with Git take place on the command line. Can you give some details of what it's doing? What are the remote names? I see it's origin. Fortunately, you can just do something like git rebase -i HEAD~2 to quickly drop the commits from your new branch. creates a local copy of a remote branch which you shouldn’t manipulate directly; instead create a proper local branch and work on that. We like to never solve the same problem twice, so documenting our solutions is an important part of our daily work. " On GitHub, navigate to the main page of the repository. Deleting a branch on a local host machine repo is easy: git branch -d To remove a branch from the remote git repository, like a GitHub-hosted repository, you can execute: git push --delete If you learned something here, check out Delete Merged Branches with git!. git an alternative to git-filter-branch. Deletes all branches in a git repository except next and master (clean git repo) delete local *and* remote git repos if merged into local master. After your super-important fix is deployed, you're ready to switch back to the work you were doing before you were interrupted. During the normal course of development, the HEAD usually points to master or some other local branch, but when you check out a previous commit, HEAD no longer points to a branch—it points directly to a commit. * Disclaimer - My_New_Branch is a terrible name for a branch, always be descriptive and imagine you are naming it for someone else who doesn't know the project to read. git remote prune origin prunes tracking branches not on the remote. Delete Git branch locally and remotely 07 August 2015 Comments Posted in Source Control, git. This command should delete the branch from the local repo even it is not fully merged. It is meant for small teams who are adopting Git for the first time, and want to get started quickly with a familiar setup before exploring Git's many new possibilities. Deleting a branch. You can see your local and remote branches in this menu too, as well as current active branch. Remove a local branch from your machine git branch -d {the_local_branch_name} (use -D instead to force deletion, without checking merged status) Remove a remote branch from the server git push origin --delete {the_remote_branch_name}. You can delete it via "git branch -d ". In the meanwhile, if you do a git fetch, you will get that new feature branch on your local. Issue tracking with branch-based pull requests. It's the master branch of your fork. > Longer answer: the pu branch in git. Back to our initial topic, deleting the Git branch: this command should remove the br-tst-1 branch from the local repo. 0 release/8. We like to never solve the same problem twice, so documenting our solutions is an important part of our daily work. Delete Remote Git Branch: – Use the following command to remove any branch from remote server. $ git branch -m Rename a Remote Git Branch. We will also specify the local branch we want to delete. They would just branch, push, create a pull request and then delete the branch (manually or via git fetch prune) as soon as the PR is merged. Above the list of files, click NUMBER branches. Git shows an asterisk mark before currently checked out branch. For example, to delete a local branch named feature/my-new-feature, we would use run the following command. Bitbucket gives teams one place to plan projects, collaborate on code, test, and deploy. It is meant for small teams who are adopting Git for the first time, and want to get started quickly with a familiar setup before exploring Git's many new possibilities. Git also enables you to delete sensitive information from your past commits and it does modify history in the progress. Inspired by this stackoverflow answer, I wanted to write a bash function that could handle more than the scenario of “delete all local git branches except for master”. Git commands are used for sharing and combining the code easily with other developers. 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 Jun 23, 2019; Git: Delete all remote branches except master. Right click dev branch and click Delete. It doesn't let you switch between branches or put a forked history back together again. git clean -fd This git clean command will remove all new directories. Once a branch is merged, it serves no purpose except for historical research. November 10th, 2018. Now you've got a master branch. GitHub is a web-based graphical interface Git or version control repository that mostly used for code. commands, files, etc). First git branch will list all the local branches. During a development, a lot of branches are created on Git for all features or evolutions. Delete old local branches. To checkout from remote git branch you have to make your local system aware of remote branches by fetching the remote branches to your local system and setting up git branch tracking so that your local and remote systems are aware of commit changes. You can also go to the branches tab and manage or delete branches there. All source code included in the card Git: Remove information on branches that were deleted on origin is licensed under the license stated below. In this post I will only explain how to delete a commit in your local repository and in a remote repository in case you have already pushed the commit. The xargs command passes the branch names with their manipulations to the git command: xargs -n 1 git push --delete origin Remove merged local branches. Github has an options to delete a branch after merging of pull request. It will list all available branches, the current branch will be preceded with a *. git push How to delete a local and remote branch. Push to remote branch and delete. In order find what's your current branch use the command "git branch -a". After git clean, your workspace is as fresh as it was following your most recent commit: $ git status # On branch add-cool-new-feature nothing to commit, working directory clean I hope this little Git productivity boost has been helpful. Delete a git branch local and remote. Right-click the selected branch and choose Delete Branch from the popup. Then by rerunning the git status command, you should get a response from Git that you are in a clean working directory and you got nothing more to commit. [[email protected] src]$ git branch new_branch [[email protected] src]$ git branch * master new_branch A new branch is created; Tom used the git branch command to list the available branches. This tutorial will help you to clone a specific git branch from the remote git repository via command line. Git only tracks the content of files. I am using Github and also SourceTree. git rm wasn't doing the job well, it only removes the folder from the working tree and the repository still contains the objects of this folder. We'll begin with the following assumptions: you have a user branch that is tracking a remote/upstream, you have local edits that you want to discard and you want to reset local to the latest remote/upstream commit. then revert to that commit: git revert -m 1 With ‘-m 1’ we tell git to revert to the first parent of the mergecommit on the master branch. Start typing “Git: Delete” and select Git: Delete Branch when it becomes visible. Let's assume our work on "contact-form" is done and we've already integrated it into "master". In most cases, solution to merge-conflict is as simple as discarding local changes or remote/other branch changes. If you want to delete a local tag then you would do git tag -d But if you want to delete remote tag, then the syntax is a little different. You can delete a remote branch using the same method - locate the tree for the remote in Team Explorer's Branches view (such as remotes/origin), right-click and select Delete. Deleting one or more local branches is trivial: git branch --delete branch branch2. The SSH, HTTP, & GIT protocols are supported and ready-to-go out of the box. The "-u" option is available only from git 1. GIT_LOCAL_BRANCH - Name of the branch on Jenkins. Finally you can call the git command to delete the remote branch. You cannot delete branches that are associated with open pull requests. One of the reasons why Git is so fast when compared to other SCM tools is because all changes are made locally rather than on a remote server. Just a quick git tip I found that has been really useful in my git-management workflow. Branches are essentially pointers to a certain commit. To delete a local branch, do the following: If you are currently on the local branch you want to delete, switch to another branch first. I did some commits in a local branch through intellij in multiple git repositories. You can delete it with the -d option to git branch:. How to delete local git branches after the merge From time to time we all get annoyed by the git branch autocomplete , which used to be so useful, but now makes us practically write the whole branch name! 😡. The git plugin supports username / password credentials and private key credentials provided by the Jenkins credentials plugin. Delete all local branches that have been merged into master [Windows]. To delete a remote branch, we do not use the "git branch" command - but instead "git push" with the "--delete" flag: $ git push origin --delete feature/login Deleting both a local and a remote branch. Delete a git branch local and remote. Tried to remove the file in GitHub ui interface, it does not let me remove Used the below to checkout the file from master Git checkout master Test1. Feature Branch Workflow. git push How to delete a local and remote branch. However, it’s important to note that Github Pages will only publish from the repo on Github. > git branch release/7. You can create and checkout branches directly within VS code through the Git: Create Branch and Git: Checkout to commands in the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)). The “-b” option to git checkout creates a new branch from an existing one. References. It is common and recommended practice to delete the branch after a successful merge. If you mistakenly added a tag or branch, and want to remove it (assuming you haven't created a release with the tag, or committed anything. Need to delete a branch in GitHub? It's a simple operation and keeping your repo clean & tidy is incredibly important in any project. There are lots of tutorials online to teach you the basics of this great system; that’s not the intent of this post. To delete an unnecessary local branch, complete the following steps: Choose Team > Repository Browser from the main menu. Warning: The below technique to force git pull will delete your local changes. If you're trying this out in a live. How can I clean up all these old local git branches? Stale/unused git branches build up rather quickly, and this is something that has resurfaced a number of times in our team chat at work. To delete a local branch, make sure that this branch is not currently checked out. Delete a Local Branch. To delete a local tracking branch (without deleting the remote branch), do:. By Mike Farmer June 21, 2012 Perhaps you've made the same mistake I have. git fetch --prune Prune local branches which have been merged. and how to list the branches. Jason Meridth posted on reseting / reverting git commits and I had a question in the comments. This video will demonstrate how to remove a GitHub repository from within Visual Studio. Not much new to understand here. The core philosophy of Git, however. -m 2 would specify to revert to the first parent on the develop branch where the merge came from initially. Dealing with git branches is something which every developer would have come across unless you are living in a cave. git branch -r to show all the remote branches git checkout --track -b new_branch origin/new_feature_name. To checkout from remote git branch you have to make your local system aware of remote branches by fetching the remote branches to your local system and setting up git branch tracking so that your local and remote systems are aware of commit changes. To learn to delete the branch's latest commits; Revert is a powerful command of the previous section that allows you to cancel any commits to the repository. Deleting remote branches in Git. The pictorial representation of create branch operation is shown below − Switch between Branches. in order to actually work on it) you can do that with git branch –track or git checkout –track -b, which is similar but it also switches your working tree to the newly created local branch. The xargs command passes the branch names with their manipulations to the git command: xargs -n 1 git push --delete origin Remove merged local branches. Here's a quick walkthrough to help you reset a local git branch to remote. In other words svn-migration-scripts. Delete all local branches except master. It's shorter and easier to remember. A new git repo (`git init`) comes with various hook examples in the `. Need to delete a branch in GitHub? It's a simple operation and keeping your repo clean & tidy is incredibly important in any project. We’ll give you the option to create a new branch: We’ll. Then, you want to change the remote branch. You can see your local and remote branches in this menu too, as well as current active branch. Ensure you are in the default branch: git checkout master. This was a stumper for me a while back. Because you are creating a branch to work on something new, every time you create a new branch (with git branch), you want to make sure to check it out (with git checkout) if you're going to use it. August 1, 2018 Pramod T P. Now you’re in the master branch again, with Part II in the working directory. Module-based. mnemonicprefix=false -c core. bash_profile or. git branch -r. When I run git branch I get: $ git branch add-readme. You accidentally deleted a branch in your Git repository. and then add, commit, and push changes. Learn more. Github has an options to delete a branch after merging of pull request. The git delete-merged-on-origin command is one of the commands available with the Iron Code Studio Git Configuration I use. Time to delete this baggage. " On GitHub, navigate to the main page of the repository. Above answers works fine. Create a new PHP project in our Eclipse workspace. Delete a Branch in AWS CodeCommit. If you need to delete a Git branch in your own repo from Visual Studio or the command line, follow these steps in the Azure Repos Git tutorial. git clean -fd This git clean command will remove all new directories. Use other branches for development and merge them back to the master branch upon completion. Simply delete your remote tracking branch: git branch -d -r origin/ (This will not delete the branch on the remote repo!) See "Having a hard time understanding git-fetch" there's no such concept of local tracking branches, only remote tracking branches. Create a branch called "temp" by typing: git branch temp. To learn to delete the branch's latest commits; Revert is a powerful command of the previous section that allows you to cancel any commits to the repository. Clean up branches right from the web. How to delete a tag in Git If you use tags in your projects, you probably have encountered some issue (typos, perhaps) that forced you to remove the tag. This tutorial provides a list of the most common GIT commands, a short description for them and example usage. $ git branch -d part2 # Delete "part2" branch. That will delete the newfeature branch on the origin remote, but you'll still need to delete the branch locally with git branch -d newfeature. git is a distributed version control system. Run the following command. Let's say the git remote repository has the following branches master develop bug-fix-3 bug-fix-4 and your local repository has the following branches master develop bug-fix-1 bug-fix-2 bug-fix-3 As you see the branches bug-fix-1 and bug-fix-2 doesn't exist on the remote. Cleanup remote git repository of all branches already merged into master. Lots of old branches piling up in your Git repo? Easily delete them from the web. Learn Git Branching $ Git Hg Hg. That sucks! Let's make it quicker and easier using a bash alias. Payload Tracking (Git) in Resolve & Source Control Tab doesn't track newer commits and can't be modified 0 Solution Unable to authenticate to TFS over SSL protocol from Android Studio plugin 1 Solution Users/groups added to branch security disappear after refreshing 0 Solution. git branch -d the_local_branch. I stumble across this one every so often. To get the list of all local branches After that, you can iterate over all local branches and get some technical details like. You have a lot of local branches. In this video Chad Thompson demonstrates how to rename a branch, both locally and remotely. To delete a remote branch you need to push the delete: git push remote--delete branch. All source code included in the card Git: Delete a branch (local or remote) is licensed under the license stated below. Its tedious to type shit out. Next time you git fetch, the branch will be back! Instead, you'll want to run git push origin :master. For example, to delete a local branch named feature/my-new-feature, we would use run the following command. create a new branch named "feature_x" and switch to it using git checkout -b feature_x switch back to master git checkout master and delete the branch again git branch -d feature_x. Here is another approach when we have lot of branches in local repo and we have to delete many branches except few which are lying in local machine. Tho oddly git push origin :refs/tags/12345 renamed my repo on github, so I'm using git push origin :[tag] to delete a remote branch instead. I am using Github and also SourceTree. If you ‘checkout’ a local copy of a remote. When working on a Git managed project, you can delete local branches you created from your Talend Studio. During a development, a lot of branches are created on Git for all features or evolutions. makandra cards used to be our in-house knowledge base where developers shared HOWTOs with each other. Approve code review more efficiently with pull requests. Deleting Branches. Usei o comando para deletar o repositório remoto e deu erro falando que não há nenhum branch. In this case this is normal and expected, your local branch is different then origin version because of rebase. Visualizing Your Git Repository. Deleting the local branch. Deletes all branches in a git repository except next and master (clean git repo) delete local *and* remote git repos if merged into local master. Does it remove local branches not on origin? What if I have 2 remotes, origin and upstream and I want to remove all the branches from origin that are not on upstream?. One of the reasons why Git is so fast when compared to other SCM tools is because all changes are made locally rather than on a remote server. It provides for each project access control and several collaboration features like bug tracking, feature requests, task management, and wikis. Tidy as we are, we also delete the remote branch by using the "git push" command with the "--delete" flag: $ git push origin --delete contact-form. The git branch command lets you create, list, rename, and delete branches. In the same repository, you can create different branches to make the code evolve independently in each of them. In this article, I explain how reset works both Git and Visual Studio. $ git branch -d issue1 Deleted branch issue1 (was b2b23c4). This tutorial explains the following git branch command examples: Create a New git Branch; Delete a Git branch; Delete remote-tracking branches; Switch to a New git Branch to Work; Create a New Branch and Switch Immediately. This shows you what Git is doing internally when you delete a local branch. Use a simple --delete option to delete a branch from your local git. Don't try to just overwrite files in branch x with files in branch y because it will screw up future merges. However if you want to delete regardless of the merge state: git branch -D branch branch2. To do it, you'll need to rename the local branch, delete the remote branch, and then push the renamed local branch to the remote repo again. Anthony Dentinger showed me in the comments that you can delete a local commit by doing: git reset –hard HEAD~. That will delete the newfeature branch on the origin remote, but you’ll still need to delete the branch locally with git branch -d newfeature. In this article, I will explore the GitHub Extension for Visual Studio 2017. Creating Local Git Repositories with Sourcetree Storing a repository locally on your hard drive sort of defeats the purpose behind Git’s design…it’s not on a remote server with timely backups, and you’re basically the only one who can access and maintain it. There’s a script called git-publish-branch created by William Morgan that can easily automate this process if you find yourself performing these actions frequently. Git docs source. This seems to work in the majority of cases, however it's causing an issue in the scenario where another instance of the git repo (e. You can no longer do git push --force sha1:master as you do not have recent commits locally (and you can’t get them with git fetch because they do not belong to any branch anymore). makandra cards used to be our in-house knowledge base where developers shared HOWTOs with each other. This couldn't be easier: git branch -m my-hot-feature feature-15. Push your branch to the remote repository: git push -u origin feature_branch_name It’s as simple as that! What’s going on here? Git Branch explained in more detail Git Branch Git’s branching functionality lets you create new branches of a project to test ideas, isolate new features, or experiment without impacting the main project. Git - Delete Branch (Local or Remote) Posted on Thursday August 10th, 2017 Friday September 1st, 2017 by admin Normally, when you start working on some new feature, you create a new branch from the default branch (usually called master ) and work inside it. Run: git checkout master 02 Change hello. Deleting Local Git Branches. Deleting a local branch doesn’t remove the remote branch. In previous article, we saved the changes to the solution to local Git repository. I’ve known for a while that you shouldn’t commit to your master branch in Git. Note that the local dev branch is gone, but the remote origin/dev is still showing. git doesn't have a command to delete. Now you’ve got a master branch. -r means remote for branch. They would just branch, push, create a pull request and then delete the branch (manually or via git fetch prune) as soon as the PR is merged. jar does not support the prefix option of "git svn clone" and thus you should force it to be empty until supported. Payload Tracking (Git) in Resolve & Source Control Tab doesn't track newer commits and can't be modified 0 Solution Unable to authenticate to TFS over SSL protocol from Android Studio plugin 1 Solution Users/groups added to branch security disappear after refreshing 0 Solution. The default branch is usually called master. We'll begin with the following assumptions: you have a user branch that is tracking a remote/upstream, you have local edits that you want to discard and you want to reset local to the latest remote/upstream commit. Even if you create the branch from your working tree, those changes are committed to the original branch, not to the new branch. Renaming a remote branch is a bit more involved, and isn't actually possible in the same way it is for renaming local branches. git push origin :newfeature. You’ve forked some project on github. Our team loved it. Then, next time you have a static site project, you’ll be able to come back to the repository, click a button, and start working from an exact copy of your boilerplate. Inspired by this stackoverflow answer, I wanted to write a bash function that could handle more than the scenario of “delete all local git branches except for master”. if you want to delete a branch in locally you need to follow two steps checkout to any other branch delete the local branch Delete Local Branch If you want to delete a branch, first checkout to the branch other […]. and both local and remote branches with $ git branch -a. After a quick search, I found that git-filter-branch was the command I was looking for. Create a branch In your repository’s branch selector, just start typing a new branch name. However, the add-readme branch is still showing on my local machine. Anthony Dentinger showed me in the comments that you can delete a local commit by doing: git reset –hard HEAD~. js i still see the file as one of the changed file in my local repo. Local branches that have been merged into master should generally be safe to remove and can easily be accomplished via:. Remove a local branch from your machine git branch -d {the_local_branch_name} (use -D instead to force deletion, without checking merged status) Remove a remote branch from the server git push origin --delete {the_remote_branch_name}. You've forked some project on github. But only if you're absolutely sure you don't need them anymore. In this case, our branch master is a pointer to the latest commit in the chain. This may be alright for small files but this could be troublesome for large files as these would unnecessarily bloat the git repository. git merge branch-name --no-commit --no-ff See differences between the current state and a branch git diff branch-name See differences in a file, between the current state and a branch git diff branch-name path/to/file Delete a branch git branch -d new-branch-name Push the new branch git push origin new-branch-name Get all branches git fetch origin. I almost always find git clean -fd does what I need. Because of this, it's extremely important that your new branch is created off of master when working on a feature or a fix. Git commands are used for sharing and combining the code easily with other developers. Select your repository, and click "Next". After your super-important fix is deployed, you're ready to switch back to the work you were doing before you were interrupted. If you're trying this out in a live. Chances are you will have to keep looking this up and copy/paste it. git branch -d the_local_branch. This article is the third installment in the "Using Git" series. $ git branch MyDatabase2. Chances are if you've been using Git as your source control weapon of choice, you've encountered the detached head issue at some point. If you want to delete a local tag then you would do git tag -d But if you want to delete remote tag, then the syntax is a little different. If you get. xargs -n 1 git push origin --delete Execute the git remote branch delete command for each element in the list. Select your repository, and click "Next". After your super-important fix is deployed, you're ready to switch back to the work you were doing before you were interrupted. Try to synchronize your branch list with. Click Delete Branches. Sometimes we may not notice that the local branches are increasing and manually deleting branches one by one can take much time. git an alternative to git-filter-branch. In other words svn-migration-scripts. git reset --soft HEAD~1 HEAD~1 is a shorthand for the commit before head. But sometimes even I need to go old school. perhaps someone else has already deleted the branch. Git - Delete Branch (Local or Remote) Posted on Thursday August 10th, 2017 Friday September 1st, 2017 by admin Normally, when you start working on some new feature, you create a new branch from the default branch (usually called master ) and work inside it. Git beginners will learn how to use the -m flag to rename from a different branch and how to verify the change. 로컬브랜치를 삭제 하는 방법이다. Also; it is useless to keep a 3 month old branch if it has been merged to master or no longer relevant. 2 command will delete the branch in the remote, but does not delete the local version of the. This is a continuation of my earlier post about pruning deleted branches. Delete a git branch local and remote. GitSheet is a simple git cheat sheet reference for common git commands saving you time and helping you learn how to use branches, show logs, undo changes, create tags, stashes and more. Tried to remove the file in GitHub ui interface, it does not let me remove Used the below to checkout the file from master Git checkout master Test1. Free for small teams under 5 and priced to scale with Standard ($3/user/mo) or Premium ($6/user/mo) plans. Module-based. There is only one local branch to delete, so select it. Any branches on remotes will not be affected. Delete Git branch locally and remotely 07 August 2015 2 Comments Posted in Source Control, git. Git shows an asterisk mark before currently checked out branch. You don't have to delete your local branch. Start typing “Git: Delete” and select Git: Delete Branch when it becomes visible. Delete a local branch using git branch -d while checked out to a different branch. Lets learn how to delete multiple branches in git. The pictorial representation of create branch operation is shown below − Switch between Branches. When a local branch is started off a remote-tracking branch, Git sets up the branch (specifically the branch. 0 command which is lookalike to delete remote branch. The core philosophy of Git, however. The "-b" option to git checkout creates a new branch from an existing one. Git docs source. How can you remove local git branches? If you are working on a project having lots of feature branches, you’d like to remove all of once your deployment is done and all feature branches merge into master. Clone the Remote Repository. https://www. kt and its layout files and commit your changes. perhaps someone else has already deleted the branch. My specific situation was about having a branch merged at the wrong time and how to undo that merge. Deleting remote and local branches in git with source tree and command line. How can I undo those commits? I need the code changes after the undo (marked them as local changes). Tidy as we are, we also delete the remote branch by using the "git push" command with the "--delete" flag: $ git push origin --delete contact-form. How to delete local git branches after the merge From time to time we all get annoyed by the git branch autocomplete , which used to be so useful, but now makes us practically write the whole branch name! 😡. You push the branch to GitHub, open a pull request, and later the branch gets merged and deleted through the GitHub web interface. git reset --soft HEAD~1 HEAD~1 is a shorthand for the commit before head. commands, files, etc). $ submit files # Release to the world! $ git merge part2 # Merge in Part II. At this step, Git deleted the file on the local repository only, but if you went to the remote repository on GitHub, you'd find that the file still exists there. To learn to delete the branch's latest commits; Revert is a powerful command of the previous section that allows you to cancel any commits to the repository. Remember, this will only delete the branch from local repository. You're right in the middle of developing a feature when a request comes up to fix a different completely unrelated problem. local에서 feature-01이라는 branch를 작성하고 싶을때는, 다음과 같은 command를 통해서 feature-01 branch를 생성할 수 있습니다. It may also be a good idea to clone your current repo, and test these solutions out first. Add some files to the local repo and push them to the CodeCommit repository. Recurring Add modified files to Git staging area then (optionally) remove modified files from Git staging area. Using Git with a central repository By Abhijit Menon-Sen. How can I clean up all these old local git branches? Stale/unused git branches build up rather quickly, and this is something that has resurfaced a number of times in our team chat at work. SourceTree delete all local branches under a specific directory In SourceTree, I have about 30 branches showing up in the directory tree under a custom directory, it looks like this: > File Status. # delete local branch git branch -D branchName # delete remote branch git push --delete origin remoteBranchName Finding merged branches for deletion # find merged branches into master git branch --merged master # when you're on master you can omit 'master' at the end git branch --merged # count results/line output git branch --merged | wc -l. I've seen even long time users of Git get stumped on this issue.