ssh를 통한 git clone
git 저장소를 만든 프로젝트가 있습니다.
$ cd myproject
$ git init
$ git add .
$ git commit
다른 머신에서 베어 클론을 생성하고 싶었습니다.
$ cd ..
$ git clone --bare myproject ssh://user@server:/GitRepos/myproject.git
클론을 실행했지만 답변을 인쇄하지 않았습니다. 서버 컴퓨터에 로그온하여 파일 저장 방법을 확인하려고했습니다. / GitRepos 경로가 비어 있으므로 복제본을 다시 수행하기로 결정했습니다.
$ git clone --bare myproject ssh://user@server:/GitRepos/myproject.git
이번에는 대답은 다음과 같습니다.
치명적 : 대상 경로 'ssh : // user @ server : /GitRepos/myproject.git'이 이미 존재하며 빈 디렉토리가 아닙니다.
그러나 나는 길이 비어있는 것을 보았다.
무슨 일이야?
이것은 아마도 질문과 직접 관련이 없습니다. 그러나 내가 방금 만든 실수 중 하나는 OP에서 알 수 있듯이 URL 사양입니다 ssh://user@server:/GitRepos/myproject.git
. 즉 절대 경로를 나타내는 후 콜론 :
과 슬래시가 /
있습니다.
그런 다음 Git 클론 을 찾았습니다 . ssh : 호스트 이름을 확인할 수 없습니다 – git, 개발 – Nicolas Kuttler ( git
버전 1.7.9.5 에서 발생한 오류 이므로) :
처음에 사용한 명령의 문제점은 scp와 같은 구문을 사용하려고 시도했다는 것입니다.
... 또한 내 문제였습니다! 기본적으로와 git
함께 ssh
,
ssh://username@host.xz/absolute/path/to/repo.git/
-서버의 절대 경로에 대한 슬래시username@host.xz:relative/path/to/repo.git/
-콜론 (ssh://
서버의 상대 경로 가 없어야 함 (username
서버 시스템 의 홈 디렉토리와 관련 )
이것이 누군가에게 도움이
되기를 바랍니다 , 건배!
GitHub의 리포지토리를 보려면 다음을 시도하십시오.
git clone ssh://git@github.com/<user>/<repository name>.git
ssh를 통해 복제하도록 git을 설정하려면 다음을 참조하십시오.
SSH 키 생성 및 계정 설정-> SSH 키 에서 생성 된 키 추가
서버를 호출하는 대상에서 clone 명령을 실행해야합니다. 그러나 로컬 클라이언트에서 ssh 서버를 실행하지 않아 어쨌든 작동하지 않을 것입니다. 이 접근법을 따르도록 제안하십시오 (메모리 에서이 작업을 수행하기 때문에 매뉴얼을 확인하십시오)
- 서버 머신에 로그인하십시오.
- 다음을 사용하여 Bare Repo 작성
git init --bare
- 클라이언트 시스템에서 리포지를 서버로 푸시 할 수 있습니다.
git remote add origin ssh://user@server:/GitRepos/myproject.git
뒤에git push origin master
힘내 101 :
git
분산 버전 관리 시스템입니다. git을 시작하고 실행하기 위해 서버가 필요하지 않습니다. 여전히 멋져 보이기 때문에 그렇게하고 싶습니까? 여러 컴퓨터에서 단일 프로젝트로 작업하려는 경우에도 유용합니다.
따라서 "서버"를 실행하려면 실행해야합니다 git init --bare <your_project>.git
. 빈 저장소가 만들어 져서 .git
디렉토리의 구성 파일을 가져 가지 않고도 컴퓨터에서 가져올 수 있습니다 .
이 후에는 작동하도록 클라이언트에서 저장소를 복제 할 수 있지만 일부 클라이언트 (즉 git-gui
)는 완전히 비어있는 저장소를 복제하지 못합니다. 이 문제를 해결하려면 다음을 실행해야합니다 cd <your_project>.git && touch <some_random_file> && git add <some_random_file> && git commit && git push origin master
. (과거에 이전에 수행하지 않은 경우 해당 시스템의 git에 대한 사용자 이름과 이메일을 구성해야 할 수도 있습니다. 실제로 실행할 명령은 오류 메시지에 표시되므로 생략하겠습니다.)
따라서이 시점에서 간단히 실행하여 리포지토리를 모든 컴퓨터에 복제 할 수 있습니다 git clone <user>@<server>:<relative_path><your_project>.git
. (다른 사람들이 지적했듯이 ssh://
절대 경로를 사용하는 경우 접두사를 접두사가 필요할 수 있습니다 .) 클라이언트에서 서버로 이미 로그인 할 수 있다고 가정합니다. ( ssh
원격 서버로 많은 것을 푸시하려는 경우 구성 파일 및 키 설정에 대한 보너스 포인트가 제공 됩니다.)
관련 링크 :
이것은 당신이 알아야 할 것을 거의 알려줍니다.
그리고 이것은 git의 기본 작업을 알고 있지만 때로는 정확한 구문을 잊어 버린 사람들을위한 것입니다.
우선, 나는 GIT 기술이 약간 부족합니다.
That is going to clone a bare repository on your machine, which only contains the folders within .git
which is a hidden directory. execute ls -al
and you should see .git
or cd .git
inside your repository.
Can you add a description of your intent so that someone with more GIT skills can help? What is it you really want to do not how you plan on doing it?
I want to attempt an answer that includes git-flow, and three 'points' or use-cases, the git central repository, the local development and the production machine. This is not well tested.
I am giving incredibly specific commands. Instead of saying <your folder>
, I will say /root/git
. The only place where I am changing the original command is replacing my specific server name with example.com
. I will explain the folders purpose is so you can adjust it accordingly. Please let me know of any confusion and I will update the answer.
The git version on the server is 1.7.1. The server is CentOS 6.3 (Final).
The git version on the development machine is 1.8.1.1. This is Mac OS X 10.8.4.
The central repository and the production machine are on the same machine.
the central repository, which svn users can related to as 'server' is configured as follows. I have a folder /root/git
where I keep all my git repositories. I want to create a git repository for a project I call 'flowers'.
cd /root/git
git clone --bare flowers flowers.git
The git command gave two messages:
Initialized empty Git repository in /root/git/flowers.git/
warning: You appear to have cloned an empty repository.
Nothing to worry about.
On the development machine is configured as follows. I have a folder /home/kinjal/Sites
where I put all my projects. I now want to get the central git repository.
cd /home/kinjal/Sites
git clone root@example.net:/root/git/flowers.git
This gets me to a point where I can start adding stuff to it. I first set up git flow
git flow init -d
By default this is on branch develop
. I add my code here, now. Then I need to commit to the central git repository.
git add .
git commit -am 'initial'
git push
At this point it pushed to the develop branch. I want to also add this to the master branch.
git flow release start v0.0.0 develop
git flow release finish v0.0.0
git push
Note that I did nothing between the release start and release finish. And when I did the release finish I was prompted to edit two files. This pushed the develop branch to master.
On the production site, which is on the same machine as my central git repository, I want put the repository in /var/www/vhosts/example.net
. I already have /var/www/vhosts
.
cd /var/www/vhosts
git clone file:///root/git/flowers.git example.net
If the production machine would also be on a different machine, the git clone
command would look like the one used on the development machine.
Disclaimer: This is just a copy of a comment by bobbaluba made more visible for future visitors. It helped me more than any other answer.
You have to drop the ssh://
prefix when using git clone
as an example
git clone git@github.com:owner/repo.git
I did : git clone --bare "/GITREPOSITORIES/RepoA" "ssh://luc@EERSTENASDS119J/volume1/RepoA" Result : fatal: destination path 'ssh://luc@EERSTENASDS119J/volume1/RepoA' already exists and is not an empty directory.
The system created a directory ssh://luc@EERSTENASDS119J/volume1/RepoA in my current path.
So git clone did not interpret the URL specification. Used the workaround of Alec.
git clone git@server:Example/proyect.git
참고URL : https://stackoverflow.com/questions/6167905/git-clone-through-ssh
'development' 카테고리의 다른 글
gets 함수가 왜 그렇게 사용되어서는 안되는 위험한가요? (0) | 2020.05.06 |
---|---|
REST API에 대한 명명 규칙이 있습니까? (0) | 2020.05.06 |
CSS에서 "."의 차이점은 무엇입니까? (0) | 2020.05.06 |
Eclipse를 사용하여 두 파일을 어떻게 비교합니까? (0) | 2020.05.06 |
파이썬에서 사전의 키워드 수 계산 (0) | 2020.05.06 |