Home » Display current Git Branch name in Terminal Prompt in Mac
Display current Git Branch name in Terminal Prompt in Mac
It’s difficult to know the name of the current active GIT branch in the terminal so let’s see how to do configuration to show active Git Branch name in Terminal.
Run below command in terminal to open the file.
sudo vim ~/.bash_profile
Add below code and save the file.
# Display current Git branch in terminal prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* (.*)/ (1)/’
}
export PS1=”u@h W[33[32m]$(parse_git_branch)[33[00m] $ “
Now access the folder where git repository is present to see that the current active git branch will display in terminal prompt.
In this article, we will learn how to rename a git branch in local and for the remote servers. If you ever faced a situation where you created a new branch, pushed your change to the remote repository, and then realized that you wrongly named your branch then you can…
There can be cases where you want to revert a branch or commits in git but due to many other commits on the top of it, Github does not show revert button for branch/commits or does not allow to revert due to other commits on the top of it. (The…
This post is useful to those who are maintaining multiple branches on multiple servers and merge production branch or any specific branch to all other branches once something gets updated to production branch or the specific branch. For example: If you have a multiple server with its respective branches and you…