macOS에서 Git을 최신 버전으로 업그레이드하는 방법은 무엇입니까?
방금 OS X Lion이 설치된 새 Mac을 구입했으며 터미널에서 기본적으로 어떤 버전의 git이 설치되어 있는지 확인했습니다. 나는 대답을 얻었다
git --version
> git version 1.7.5.4
git을 최신 버전 1.7.8.3으로 업그레이드하고 싶습니다. dmg 설치 프로그램 "git-1.7.8.3-intel-universal-snow-leopard.dmg"를 다운로드하여 시작했습니다.
설치 후에도 터미널은 여전히 버전이 1.7.5.4라고 말합니다. 내가 뭘 잘못하고 있죠?
다음을 추가하면 더 좋을 것입니다.
export PATH=/usr/local/git/bin:/usr/local/sbin:$PATH
홈 폴더에 .bashrc라는 파일로. 이런 식으로 설치 한 다른 소프트웨어 /usr/local/git/bin
도 먼저 찾을 수 있습니다.
이 작업을 쉽게 수행하려면 다음을 입력하십시오.
echo "export PATH=/usr/local/git/bin:/usr/local/sbin:$PATH" >> ~/.bashrc
터미널에 넣고 당신을 위해 그것을 할 것입니다.
Homebrew가 이미있는 경우 간단합니다. Homebrew 가 설치되어 있다고 가정하면 다음을 입력하십시오.
brew install git
설치되면 다음 두 줄을 입력하면 Apple 대신 로컬 git distro 경로가 설정됩니다.
export PATH=/usr/local/bin:$PATH
git --version
HOMEBREW가없는 경우이 단계를 수행 하십시오. 버전 확인
$ git --version
Apple git 백업 (또는 제거) (선택 사항)
$ sudo mv /usr/bin/git /usr/bin/git-apple
없는 경우 Homebrew를 설치하십시오.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
또는 이미있는 경우 업데이트
$ brew update && brew upgrade
Homebrew와 함께 Git 설치
$ brew install git
심볼릭 링크
$ brew link --force git
터미널을 닫고 다시 열고 버전을 확인하십시오
$ git --version
넌 봐야 해…
git version <latest version>
좋은! 우리는 지금 안전하다! 그리고 다음에 할 수있는 일은 ...
$ brew update && brew upgrade
최근에 OS X 컴퓨터의 Git도 최신 버전으로 업그레이드했습니다. 나는 .dmg
당신이 사용한 것과 같은 것을 사용 하지 않았지만 그것을 설치할 때 바이너리는에 배치되었습니다 /usr/local/bin
. 이제 내 방식대로 PATH
디렉토리 /usr/bin
가 앞에 나타납니다 /usr/local/bin
. 그래서 내가 한 일은 :
cd /usr/bin
mkdir git.ORIG
mv git* git.ORIG/
이렇게하면 이름이 지정된 여러 원래 프로그램 git*
이 새 하위 디렉토리로 이동하여 방해가되지 않습니다. 그 후, which git
하나를 /usr/local/bin
찾았 음을 보여줍니다 .
새 바이너리를 설치 한 위치에 맞게 위 절차를 수정하십시오.
Google에서 "Mac에서 git의 업그레이드 문제"를 검색 한 후 4 단계를 완료하여 문제를 해결하기 전에 여러 게시물을 읽고 다음을 시도했습니다.
위에서 언급 한 export 명령을 사용하여 터미널 경로를 업데이트했습니다. 터미널을 종료하고 다시 시작할 때마다 터미널을 입력
git --version
하면 여전히 이전 버전 1.8을 반환합니다..dmg 설치 프로그램과 함께 제공되는 현재 버전 2.0.1로 업그레이드하기 위해 README.txt 지침을 따랐으며 터미널을 다시 시작해도 여전히 작동하지 않습니다.
위에서 지시 한대로 / etc / path / 폴더를 찾았는데 "path"라는 디렉토리가 Mac에 없습니다. OS X Mavericks 버전 10.9.4를 실행하고 있습니다.
그런 다음 Mac에 Homebrew가 설치되어 있고 다음을 실행 한 것을 기억했습니다 .
brew --version brew update brew search git brew install git
이것은 마침내 내 문제를 해결했습니다. 왜 이것이 효과가 있었는지에 대한 통찰력이 있다면 더 많은 통찰력을 얻을 수 있습니다. 작년에 내 시스템의 일부 경로 설정이 Ruby와 작동하지 않을 수 있습니다.
homebrew를 사용하는 경우 다음을 사용하여 sim 링크를 업데이트 할 수 있습니다
brew link --overwrite git
The installer from the git homepage installs into /usr/local/git
by default. However, if you install XCode4, it will install a git version in /usr/bin
. To ensure you can easily upgrade from the website and use the latest git version, edit either your profile information to place /usr/local/git/bin
before /usr/bin
in the $PATH or edit /etc/paths
and insert /usr/local/git/bin
as the first entry.
It may help to someone at-least changing the order in /etc/paths worked for me.
the simplest way I found so far is from git official website. It just computed dependencies and downloaded all of the required libraries/tools
http://git-scm.com/book/en/Getting-Started-Installing-Git
The other major way is to install Git via MacPorts (http://www.macports.org). If you have MacPorts installed, install Git via
$ sudo port install git-core +svn +doc +bash_completion +gitweb
For me, with Homebrew 1.6.7
, the following worked:
brew upgrade git
In order to keep both versions, I just changed the value of PATH environment variable by putting the new version's git path "/usr/local/git/bin/" at the beginning, it forces to use the newest version:
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin/
$ git --version
git version 2.4.9 (Apple Git-60)
original value: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin/
new value: /usr/local/git/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
$ export PATH=/usr/local/git/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
$ git --version
git version 2.13.0
I prefer not to alter the path hierarchy, but instead deal with git specifically...knowing that I'm never going to use old git to do what new git will now manage. This is a brute force solution.
NOTE: I installed XCode on Yosemite (10.10.2) clean first.
I then installed from the binary available on git-scm.com.
$ which git
/usr/bin/git
$ cd /usr/bin
$ sudo ln -sf /usr/local/git/bin/git
$ sudo ln -sf /usr/local/git/bin/git-credential-osxkeychain
$ sudo ln -sf /usr/local/git/bin/git-cvsserver
$ sudo ln -sf /usr/local/git/bin/git-receive-pack
$ sudo ln -sf /usr/local/git/bin/git-shell
$ sudo ln -sf /usr/local/git/bin/git-upload-archive
$ sudo ln -sf /usr/local/git/bin/git-upload-pack
$ ls -la
(you should see your new symlinks)
Without Homebrew
- Use the installer from git's website.
- Update your
~/.bash_profile
file. Notice this command differs from kmikael's answer by what it puts in the file:- Other command:
export PATH=/usr/local/git/bin:/usr/local/sbin/:[and so on]
- Below command:
export PATH="/usr/local/git/bin:/usr/local/sbin:$PATH"
- Use whichever one you prefer.
- Other command:
echo 'export PATH="/usr/local/git/bin:/usr/local/sbin:$PATH"' >> ~/.bash_profile
- If you're using Xcode, you'll need to add some symbolic links.
- Example:
ln -s /opt/local/bin/git /usr/bin/git
- Example:
- Restart terminal.
which git
should say the directory in theREADME.txt
file from the dmg.git --version
should say the updated version.echo $PATH
should start with/usr/local/git/bin:/usr/local/sbin:
I did it in this way:
- Open GitHub application installed on Mac
- Click on Advanced tab → Install command line tools
- Once you get a message that all commands have been installed close your terminal and reopen it.
- Now check
git --version
, it should give you the latest version.
You need to adjust shell path , the path will be set in either .bashrc or .bash_profile in your home directory, more likely .bash_profile
So add into the path similar to the below and keep what you already have in the path, each segment is separated by a colon:
export PATH="/usr/local/bin:/usr/bin/git:/usr/bin:/usr/local/sbin:$PATH"
참고URL : https://stackoverflow.com/questions/8957862/how-to-upgrade-git-to-latest-version-on-macos
'Programming' 카테고리의 다른 글
타사 OAuth 공급자를 통한 인증을 허용하면서 OAuth로 REST API 보안 유지 (DotNetOpenAuth 사용) (0) | 2020.06.22 |
---|---|
HATEOAS (REST 아키텍처)에 대한 실제 예 (0) | 2020.06.22 |
Android Activites의 onPause ()와 onStop () ()의 차이점은 무엇입니까? (0) | 2020.06.22 |
이 서비스를 사용할 권한이 없습니다 iTunes 앱 업로드 오류 (0) | 2020.06.22 |
drawRect 또는 drawRect하지 않기 (drawRect / Core Graphics를 서브 뷰 / 이미지와 왜 사용해야 하는가?) (0) | 2020.06.22 |