We needed to set a repository specific .gitconfig for one of our projects. We discovered that we could use the git config --local
flag to make this happen. However, the server on which we wanted to do this had git version 1.7.1. The --local
flag is not available in that version of git. If we go by the entry for it in the documentation, it was first mentioned in git-config.txt in June of 2013 (commit: 560d4b8). And that commit was first released in v1.8.3.4. Anyway, an upgrade was necessary. And if we're going to upgrade, we might as well upgrade to the latest version.
This dev server for this project is running CentOS 6 in order to match the client environment:
# Check OS
cat /etc/*release*
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)
cpe:/o:centos:linux:6:GA
Upgrading from git 1.7 to 2.8 on CentOS
# Check what version of git current repo's provide
yum provides git
git-1.7.1-4.el6_7.1.x86_64 : Fast Version Control System
# Get IUS repo setup script
curl 'https://setup.ius.io/' -o setup-ius.sh
# Run setup script
sudo sh setup-ius.sh
# Recheck available versions
yum provides git
git2u-2.9.2-1.ius.centos6.x86_64 : Fast Version Control System
git-1.7.1-4.el6_7.1.x86_64 : Fast Version Control System
# Check what version of git the repo provides
yum --enablerepo=ius list git*
# Remove old git
sudo yum remove git
# Install git from new repo
sudo yum --enablerepo=ius install git2u
# Verify version
git --version
git version 2.9.2
Now that we have the latest version of Git, we can tell it to use our local .gitconfig:
# Change into repo
cd repo/
# Check git config
cat .gitconfig
[core]
autocrlf = input
# Tell git to include local config
git config --local include.path ../.gitconfig
# Verify
git config core.autocrlf
input
On to the next one...
Resources
- http://stackoverflow.com/questions/18329621/storing-git-config-as-part-of-the-repository
- https://answers.atlassian.com/questions/52498/stash-requires-git-1-7-6-but-rhel6-comes-with-git-1-7-1
- http://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-6-x-7-x
- http://www.2daygeek.com/install-enable-ius-community-repository-on-rhel-centos/#
- https://orrsella.com/2013/08/10/git-using-different-user-emails-for-different-repositories/
- http://www.codeography.com/2011/08/05/project-specific-git-author.html
- http://stackoverflow.com/questions/8801729/is-it-possible-to-have-different-git-config-for-different-projects