-
The git branch command shows all the branches I have created once they are merged into production can they removed to not appear when git branch is used. I am thinking a year from now that list will be very long.
-
I have very long branch names. Is there autocomplete for branch names?
Hi, not sure if this is what you want for question 1 or not, but you can use āgit branch -d branch_nameā to delete a branch. I do that from my master branch once I have merged. However, if your question is how to remove the branch from the āgit branchā output (without deleting it) I donāt know the answer.
Yes, I wanted to know how to remove the branch from the āgit branchā output (without deleting it).
If you delete the branch what happens if you need to rollback those changes? Is it possible to rollback changes after it has been merged to master?
Thanks for your reply.
I can comment on how Iād do it using bash terminal. If you know the names of the branches you want to suppress in the output you could do something like this at the command line:
$ git branch | grep -v --file=branch_list.txt
Where branch_list.txt is a file with the names you want to suppress, one branch name per line. You could make that command into an alias so you donāt have to type the command each time.
$ alias gitbranch="git branch | grep -v --file=branch_list.txt"
And then put that in your .bashrc file (may be a slightly different name on your system) so the alias loads automatically and will be available for you anytime you launch terminal.
For your other question about rollbacks, I thought that once you merge you are still able to revert to previous commits. But I have a fuzzy understanding of how youād do that in all situations, and what the exact limitations are. So youāll need to check that out further. Iād start here for ideas and see where that leads:
$ git help revert
$ git help reset
$ git help reflog
@kimkan Yes, there is autocomplete on branch names, and it works just like bash autocomplete: to finish the name, or again to show a list of multiple matches.
Thank JESii. What is the command for branch name autocomplete? Or do you know where I can find the instructions on how to get this to work on my system? I am using Mac OS X.
Thank you cs7. I will try your suggestions. This may be exactly what I was looking for!!
I tried this link and it didnāt work for my Mac OS X environment.
I found these instructions for installing autocomplete script using homebrew and they are not working either. Autocomplete with homebrew install
The instructions from the āAutocomplete with homebrew installā link did work I just needed to start a new terminal.
THANKS!!!