며칠 전에 GitHub에서 프로젝트를 가져왔습니다. 나는 그 이후로 GitHub에 여러 포크가 있다는 것을 발견했고 내가 원래 가져간 포크를 기록하는 것을 소홀히 했습니다. 내가 당긴 포크를 어떻게 알 수 있습니까?
질문자 :Tim
원격 URL만 원하거나 원격 저장소에 연결할 수 있는 네트워크에 연결되어 있지 않은 경우:
git config --get remote.origin.url
당신은 최대 출력을 필요로하고 원점이 상주하는 원격 REPO에 도달 할 수있는 네트워크에있는 경우 :
git remote show origin
git clone
(GitHub 또는 해당 문제에 대한 소스 저장소에서)을 사용할 때 클론 소스의 기본 이름은 "origin"입니다. git remote show
를 사용하면 이 원격 이름에 대한 정보가 표시됩니다. 처음 몇 줄은 다음과 같이 표시되어야 합니다.
C:\Users\jaredpar\VsVim> git remote show origin * remote origin Fetch URL: git@github.com:jaredpar/VsVim.git Push URL: git@github.com:jaredpar/VsVim.git HEAD branch: master Remote branches:
스크립트의 값을 사용하려면 이 답변에 나열된 첫 번째 명령을 사용합니다.
JaredPar
스크립팅 목적으로 이것을 원하면 다음을 사용하여 URL만 얻을 수 있습니다.
git config --get remote.origin.url
Cascabel
당신은 시도 할 수 있습니다:
git remote -v
모든 리모컨의 가져오기/푸시 URL을 인쇄합니다.
Montaro
답을 얻으려면:
git ls-remote --get-url [REMOTE]
이것은 구성을 읽는 것보다 낫습니다. git-ls-remote
대한 매뉴얼 페이지를 참조하십시오.
--get-url
"url.<base>.insteadOf"
구성 설정을 고려하여 지정된 원격 저장소의 URL을 확장하고git-config(1)
) 원격지와 통신하지 않고 종료합니다.
@Jefromi가 지적한 대로 이 옵션은 v1.7.5 에 추가되었으며 v1.7.12.2 (2012-09)까지 문서화되지 않았습니다.
Carl Suster
Git 2.7(2015년 1월 5일 릴리스)에서는 git remote
사용하여 보다 일관된 솔루션을 사용할 수 있습니다.
git remote get-url origin
git remote set-url origin <newurl>
의 멋진 펜던트)
Ben Boeckel( mathstuf
)의 commit 96f78d3 (2015년 9월 16일)을 참조하십시오.
(2015년 10월 5일 커밋 e437cbd 에서 Junio C gitster
-- gitster -- 병합) :
원격: get-url 하위 명령 추가
확장
insteadOf
의 일부입니다ls-remote --url
및 확장 할 수있는 방법이 없습니다pushInsteadOf
뿐만 아니라이.
구성된 모든 URL을 가져오는 방법과 쿼리를 모두 수행할 수 있도록get-url
하위 명령을 추가합니다.
get-url:
원격의 URL을 검색합니다.
insteadOf
여기에 대한 구성 및pushInsteadOf
가 확장됩니다.
기본적으로 첫 번째 URL만 나열됩니다.
--push
'를 사용하면 URL을 가져오는 대신 푸시 URL이 쿼리됩니다.- '
--all
'을 사용하면 원격지의 모든 URL이 나열됩니다.
git 2.7 이전에는 다음이 있었습니다.
git config --get remote.[REMOTE].url git ls-remote --get-url [REMOTE] git remote show [REMOTE]
VonC
요약하자면 다음과 같은 네 가지 방법이 있습니다.
(공식 Linux 리포지토리에 대해 다음을 시도했습니다.)
최소한의 정보:
$ git config --get remote.origin.url https://github.com/torvalds/linux.git
그리고
$ git ls-remote --get-url https://github.com/torvalds/linux.git
추가 정보:
$ git remote -v origin https://github.com/torvalds/linux.git (fetch) origin https://github.com/torvalds/linux.git (push)
더 많은 정보:
$ git remote show origin * remote origin Fetch URL: https://github.com/torvalds/linux.git Push URL: https://github.com/torvalds/linux.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date)
nonopolarity
조작하지 않았다면 .git/config
및 remote["origin"]
아래에서 찾을 수 있다고 생각합니다.
meder omuraliev
저에게는 이것이 더 쉬운 방법입니다(타이핑이 적음).
$ git remote -v origin https://github.com/torvalds/linux.git (fetch) origin https://github.com/torvalds/linux.git (push)
실제로 s
라는 alias
다음을 수행합니다.
git remote -v git status
다음을 사용하여 프로필에 추가할 수 있습니다. alias s='git remote -v && git status'
Code Knox
짧은 답변:
$ git remote show -n origin
또는 순수한 빠른 스크립트의 대안:
$ git config --get remote.origin.url
일부 정보:
-
$ git remote -v
는 모든 리모컨을 인쇄합니다(원하는 것이 아님). 원산지를 원하십니까? -
$ git remote show origin
훨씬 더 좋고,origin
만 표시하지만 너무 오래 걸립니다(git 버전 1.8.1.msysgit.1에서 테스트됨).
$ git remote show -n origin
끝났습니다. 가장 빠른 것 같습니다. -n
을 사용하면 원격 헤드(일명 분기)를 가져오지 않습니다. 그런 정보는 필요없겠죠?
http://www.kernel.org/pub//software/scm/git/docs/git-remote.html
당신은 신청할 수 있습니다 | grep -i fetch
오기 URL만 표시하도록 세 가지 버전 모두로 가져옵니다.
순수한 속도가 필요한 경우 다음을 사용하십시오.
$ git config --get remote.origin.url
지적 해 주신 @Jefromi 에게 감사드립니다.
Casey
나는 Git 명령에 대한 모든 매개변수를 결코 기억할 수 없기 때문에 ~/.gitconfig
파일에 더 이해하기 쉬운 별칭을 넣어 기억할 수 있으므로 입력량이 줄어듭니다.
[alias] url = ls-remote --get-url
터미널을 다시 로드한 후 다음을 입력하면 됩니다.
> git url
다음은 내가 자주 사용하는 몇 가지 추가 사항입니다.
[alias] cd = checkout ls = branch lsr = branch --remote lst = describe --tags
또한 원격 및 로컬 분기에 대한 훨씬 더 자세한 정보를 제공 git info
명령 이 있는 git-extras 를 적극 권장합니다.
What Would Be Cool
나는 기억하기 쉽기 때문에 이것을 선호한다:
git config -l
다음과 같은 모든 유용한 정보가 나열됩니다.
user.name=Your Name user.email=your.name@notexisting.com core.autocrlf=input core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=https://github.com/mapstruct/mapstruct-examples remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master
Witold Kaczurba
Git URL은 Git 구성 파일 안에 있습니다. 값은 키 url
해당합니다.
Mac 및 Linux의 경우 아래 명령을 사용합니다.
cd project_dir cat .git/config | grep url | awk '{print $3}'
Windows의 경우 텍스트 편집기에서 아래 파일을 열고 키 url
값을 찾으십시오.
project_dir/.git/config
참고: 오프라인 상태이거나 원격 git 서버가 다운된 경우에도 작동합니다.
Harikrishnan
나는 기본적으로 다음을 사용합니다.
git remote get-url origin
Windows의 Git Bash 명령 콘솔 또는 CMD 명령 콘솔에서 작동합니다. 즉, Git 버전 2.x에서 작동합니다.
maytham-ɯɐɥʇʎɐɯ
git config --list
이 명령은 저장소와 관련된 모든 정보를 제공합니다.
Kasthuri Shravankumar
업스트림의 리모컨은 "원점"이라고 하지 않을 수 있으므로 다음과 같은 변형이 있습니다.
remote=$(git config --get branch.master.remote) url=$(git config --get remote.$remote.url) basename=$(basename "$url" .git) echo $basename
또는:
basename $(git config --get remote.$(git config --get branch.master.remote).url) .git
더 유용한 변수는 다음과 같습니다.
$ git config -l
cagney
origin
의 IP 주소/호스트 이름을 얻으려면
ssh://
저장소의 경우:
git ls-remote --get-url origin | cut -f 2 -d @ | cut -f 1 -d "/"
git://
저장소의 경우:
git ls-remote --get-url origin | cut -f 2 -d @ | cut -f 1 -d ":"
Stephen
다른 답변을 보완하려면: 리모컨이 어떤 이유로 변경되어 원래 출처를 반영하지 않는 경우 reflog의 맨 처음 항목(예: git reflog
명령으로 표시되는 마지막 항목)은 repo가 어디에 있었는지 표시해야 합니다. 원래 복제되었습니다.
예
$ git reflog | tail -n 1 f34be46 HEAD@{0}: clone: from https://github.com/git/git $
(reflog가 제거될 수 있으므로 작동이 보장되지 않는다는 점에 유의하십시오.)
Jeremy
git remote show origin
을 사용하면 프로젝트 디렉토리에 있어야 합니다. 그러나 다른 곳에서 URL을 확인하려면 다음을 사용할 수 있습니다.
cat <path2project>/.git/config | grep url
이 명령이 자주 필요한 경우 .bashrc
또는 .bash_profile
별칭을 정의할 수 있습니다.
alias giturl='cat ./.git/config | grep url'
따라서 단순히 URL을 얻으려면 Git 루트 폴더에서 giturl
을 호출하기만 하면 됩니다.
이 별칭을 다음과 같이 확장하면
alias giturl='cat .git/config | grep -i url | cut -d'=' -f 2'
이전 없이 일반 URL만 얻습니다.
"URL="
~에
당신은 그것의 사용법에 있는 더 많은 가능성을 얻습니다:
예시
Mac에서는 open $(giturl)
을 호출하여 표준 브라우저에서 URL을 열 수 있습니다.
또는 chrome $(giturl)
을 사용하여 Linux의 Chrome 브라우저에서 엽니다.
Sedat Kilinc
.git/config
파일을 여는 것입니다.
cat .git/config
편집:
vim .git/config
또는
nano .git/config
Omar Makled
SSH 클론으로 리포지토리를 복제했습니다.
git config --get remote.origin.url git@gitlab.com:company/product/production.git
그러나 브라우저에서 열거나 공유하기 위해 http url을 얻고 싶습니다.
git config --get remote.origin.url | sed -e 's/:/\//g'| sed -e 's/ssh\/\/\///g'| sed -e 's/git@/https:\/\//g' https://gitlab.com/company/product/production.git
GitHub 또는 GitLab은 중요하지 않습니다.
Aidar Gatin
임의로 명명된 원격 가져오기 URL 인쇄:
git remote -v | grep fetch | awk '{print $2}'
Aron
브랜치에 대한 업스트림 리모트의 이름을 모르는 경우 현재 브랜치가 구축된 업스트림 브랜치 이름을 검사하여 먼저 찾을 수 있습니다. 다음과 같이 git rev-parse
사용하십시오.
git rev-parse --symbolic-full-name --abbrev-ref @{upstream}
이것은 현재 분기의 소스였던 업스트림 분기를 보여줍니다. 다음과 같이 원격 이름을 얻기 위해 구문 분석할 수 있습니다.
git rev-parse --symbolic-full-name --abbrev-ref @{upstream} | cut -d / -f 1
이제 그것을 가져 와서 git ls-remote
파이프하면 현재 분기의 소스 인 업스트림 원격의 URL을 얻을 수 있습니다.
git ls-remote --get-url \ $(git rev-parse --symbolic-full-name --abbrev-ref @{upstream} | cut -d / -f 1)
이제 이것이 복제된 원본 원격 저장소와 반드시 같지는 않다는 점에 유의해야 합니다. 그러나 많은 경우에 충분할 것입니다.
Christopher
#!/bin/bash git-remote-url() { local rmt=$1; shift || { printf "Usage: git-remote-url [REMOTE]\n" >&2; return 1; } local url if ! git config --get remote.${rmt}.url &>/dev/null; then printf "%s\n" "Error: not a valid remote name" && return 1 # Verify remote using 'git remote -v' command fi url=`git config --get remote.${rmt}.url` # Parse remote if local clone used SSH checkout [[ "$url" == git@* ]] \ && { url="https://github.com/${url##*:}" >&2; }; \ { url="${url%%.git}" >&2; }; printf "%s\n" "$url" }
용법:
# Either launch a new terminal and copy `git-remote-url` into the current shell process, # or create a shell script and add it to the PATH to enable command invocation with bash. # Create a local clone of your repo with SSH, or HTTPS git clone git@github.com:your-username/your-repository.git cd your-repository git-remote-url origin
산출:
https://github.com/your-username/your-repository
ecwpz91
원격 URL만 가져오려면:
git config --get remote.origin.url
특정 리모컨에 대한 자세한 내용을 보려면 다음을 사용하십시오.
git remote show [remote-name] command
원격 URL을 보려면
git remote show origin
.git 폴더가 있는 위치를 보려면
git config --get remote.origin.url
ßãlãjî
.git 폴더가 있는 위치에 이 명령을 사용하면 됩니다.
git config --get remote.origin.url
네트워크에 연결된 경우
git remote show origin
로컬 Git 리포지토리가 원래 복제된 URL이 표시됩니다.
이 도움을 바랍니다
Ali Raza
alias git-repo="git config --get remote.origin.url | sed -e 's/:/\//g'| sed -e 's/ssh\/\/\///g'| sed -e 's/git@/https:\/\//g'" alias git-pr="git config --get remote.origin.url | sed -e 's/:/\//g'| sed -e 's/ssh\/\/\///g'| sed -e 's/git@/https:\/\//g' | sed 's/....$//' | sed -ne 's/$/\/pulls &/p'"
이 표현을 기본 디렉토리의 .zshrc 또는 .bashrcs에 추가하십시오.
다음과 같이 사용할 수 있습니다.
git-repo git-pr
Hasan Tezcan
출처 : 여기를 클릭하세요
출처 : http:www.stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr
'etc. > StackOverFlow' 카테고리의 다른 글
원격 Git 리포지토리의 URI(URL)를 변경하는 방법은 무엇입니까? (0) | 2021.10.01 |
---|---|
RESTful 프로그래밍이란 정확히 무엇입니까? (0) | 2021.10.01 |
Git 리포지토리에서 병합 충돌을 해결하는 방법 (0) | 2021.10.01 |
JavaScript 링크에 "#" 또는 "javascript:void(0)" 중 어떤 "href" 값을 사용해야 합니까? (0) | 2021.09.30 |
CSS로 HTML5 입력의 자리 표시자 색상 변경 (0) | 2021.09.30 |