Re: [git-users] Fully compatibly way to get git branch and current SHA
On Friday, January 4, 2013 5:30:20 AM UTC+1, Yoshiki Vázquez Baeza wrote: Hello John, Thanks for the prompt response, this brings me to a second question, is there a standard version of git that is installed in most systems or what seems to be the most widely used version of git that people use. Sorry if this question is to broad. No, some operating systems come pre-installed with some version of Git, others have settled on some version. As operating systems are used in various versions, and each of them will have their own considered stable versions of Git, it's hard to say which is the most common. Luckily, there is an annual Git Survey which investigates this, among other things: https://git.wiki.kernel.org/index.php/GitSurvey2012 As you can see in there, most people are on Git 1.7 (84%), and some (probably more by now) have gone on to 1.8 (10%). In my opinion, it would be fair to require your users to upgrade to Git 1.7 or newer. --
Re: [git-users] Fully compatibly way to get git branch and current SHA
#current branch name git branch #or branch=$(git branch | cut -d ' ' -f 2) #sha of head head=$(cat .git/refs/heads/${branch} I don't know for certain that these will work for all releases. -- Maranatha! John McKown On Jan 3, 2013 9:41 PM, Yoshiki Vázquez Baeza yoshik...@gmail.com wrote: Hello everyone, I'm currently having a problem trying to retrieve the current git branch and the current git SHA of a repository, the main problem being that the method I'm using does not work in different versions of git. Right now I'm pulling out this information with the following two commands: # first seven chars of the SHA git rev-parse --short HEAD # current branch name git rev-parse --abbrev-ref HEAD The second command does not work in git 1.7 and lower (I think), the first command only works in versions greater than or equal to 1.5.2. *What would be a more effective way to achieve this without having to check for the current git version*? What I would like would be a command that would work in any git version or that has the greatest coverage for the multiple versions available. Thanks! Yoshiki. -- --
Re: [git-users] Fully compatibly way to get git branch and current SHA
Hello John, Thanks for the prompt response, this brings me to a second question, is there a standard version of git that is installed in most systems or what seems to be the most widely used version of git that people use. Sorry if this question is to broad. Further tests show me that the commands I previously sent would work in 1.6.4.5 but starting 1.6.5 would not work until 1.6.6 where it would work again. There are several intermittent periods of non-usability which seem like a very weird thing to me. Also, does this type of question belong here or should this be sent to a different mailing list? Thanks! Yoshiki. El 03/01/2013, a las 21:53, John McKown escribió: #current branch name git branch #or branch=$(git branch | cut -d ' ' -f 2) #sha of head head=$(cat .git/refs/heads/${branch} I don't know for certain that these will work for all releases. -- Maranatha! John McKown On Jan 3, 2013 9:41 PM, Yoshiki Vázquez Baeza yoshik...@gmail.com wrote: Hello everyone, I'm currently having a problem trying to retrieve the current git branch and the current git SHA of a repository, the main problem being that the method I'm using does not work in different versions of git. Right now I'm pulling out this information with the following two commands: # first seven chars of the SHA git rev-parse --short HEAD # current branch name git rev-parse --abbrev-ref HEAD The second command does not work in git 1.7 and lower (I think), the first command only works in versions greater than or equal to 1.5.2. What would be a more effective way to achieve this without having to check for the current git version? What I would like would be a command that would work in any git version or that has the greatest coverage for the multiple versions available. Thanks! Yoshiki. -- -- --