PDA

View Full Version : git question



christoforever
January 3rd, 2009, 04:48 AM
just a quick question if anyone knows off the top of their heads. I'm using git in a java program and want to return as a String the current working branch. using git branch lists all branches with the working branch having a star infront of it. So i've tried using git grep but cant seem to return the line... I thought maybe something like git grep "*" branch but that just returns the next line. So if anyone has any ideas that would be cool.

Thanks in advance,

Christopher Dancy

christoforever
January 3rd, 2009, 04:55 AM
I did solve it this way, however I wanted it to be cross platform seeing as how some version of git is working on windows and the pipe operator I dont believe works on windows. I could use java's regular expression to pull out the line but I was wondering if there was a simple way in git to do it.

Solved: Unix Style

git branch | grep "*"

christoforever
January 3rd, 2009, 04:56 AM
sorry I posted in wrong spot in wrong tab.

christoforever
January 3rd, 2009, 04:57 AM
I did solve it this way, however I wanted it to be cross platform seeing as how some version of git is working on windows and the pipe operator I dont believe works on windows. I could use java's regular expression to pull out the line but I was wondering if there was a simple way in git to do it.

Solved: Unix Style

git branch | grep "*"

overdrank
January 3rd, 2009, 05:07 AM
sorry I posted in wrong spot in wrong tab.

Hi and you can just use the report button and asked it to be moved :)