Tag: bash

Git – Rename multiple branches

Here we have a git repo which has multiple branches which start with the same prefix just like this: pfx.branchName1 pfx.branchName2 pfx.branchName3 … So the question is how to quickly remove all the prefixes (“pfx.”) from all the branches and get something like this: branchName1 branchName2 branchName3 …

git ps1 bash not loading on Lion

I have the following in my .bashrc file: # Git Bash Completion source “$HOME/.git_completion” GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWSTASHSTATE=1 # Prompt export PS1=”\e[0;35m\u@\h\e[m \e[0;34m\w$(__git_ps1):\e[m\r\n” This should be displaying the git branch at the end of my prompt… but it’s not. If I manually source my .bash_profile, it works (my .bash_profile loads .bashrc). If I quit terminal and startup […]

bash: check if a particular git repository has github as remote repo?

I was wondering if it is, at all, possible to check if a git repository is using github.com as remote repository, and get the url for it via bash? Any help will be appreciated.

Git won't add certain globs

I’m left scratching my head on this one. So, in git on OSX, you can add files like: git add *.java and it will add all files that have the *.java extension. Same for .txt, json, etc. However, when I do a git add *.xml nothing happens. It’s not specified in my gitignore, so git […]

Confusing error from | xargs sed

I have a little find-replace utility around git. Let’s ignore suggestions for a different approach ATM. I’m really trying to understand this error from sed. Take a look at the command function git_find_replace { local grepexp=”$1″ local replace=”$2″ # build sed command local sedcmd=”s/$grepexp/$replace/g” # First find the files; then pipe through xargs sed for […]

How to change git from Chinese to English in mac

I remember I install git through port install git-core. And it show Chinese word as default like the followings: # 位于分支 master # 您的分支领先 ‘origin/master’ 共 2 个提交。 # nothing to commit, working directory clean and # 位于分支 master # 您的分支领先 ‘origin/master’ 共 2 个提交。 # # 尚未暂存以备提交的变更: # (使用 “git add <file>…” 更新要提交的内容) # […]

Checkout branch from Github without cloning whole repo, and without Git

I’m often building servers where the goal is to install some software that is stored in Github. The process goes: Install Git. Clone the Github repo. Checkout the right branch. Steps 1 and 2 can be pretty slow (a few minutes). Are there any tools that would allow me to cut to the chase, step […]

Git: Permission Denied when Opening Text Editor

I am trying to set the text editor that will open when Git needs me to type something (e.g., message for a commit). I am on Mac OSX 10.9.5 and using bash. I have configured the default editor to TextEdit – my .gitconfig file looks like this: [user] name = My Name email = MyEmail@host.com […]

Getting git return values in shell script

I’m writing a shell script that makes some git calls. In particular, I’m looking for a way to figure out if a git rebase call is successful or if there is a merge conflict. This is what I have so far. returnStatus=$(git rebase master); if [[ returnStatus == 1 ]]; then break; else echo $branch; […]

How to hard reset from one git branch to other in JGit?

I have two branches one is master and another one level1. Now level1 is the latest I need to hard reset master to level1 normally in git bash I can do that by following command. $ git checkout master $ git tag old-master-branch $ git reset –hard level1 $ git merge -s ours origin/master $ […]

Git Baby is a git and github fan, let's start git clone.