programing

Git를 사용하여 원격 저장소에 초기 푸시를 수행하려면 어떻게 해야 합니까?

telebox 2023. 7. 16. 13:15
반응형

Git를 사용하여 원격 저장소에 초기 푸시를 수행하려면 어떻게 해야 합니까?

저는 수많은 튜토리얼을 읽었고 계속 부족합니다.제가 가진 것은 다음과 같습니다.

  • Windows 바탕 화면에서 RubyMine을 실행하는 경우
  • 나는 그들의 지시에 따라 내 WebFaction 호스팅 계정에 Git를 설치했습니다.
  • Git는 두 기계 모두에서 잘 작동하는 것 같습니다.

제가 하고 있는 일은 다음과 같습니다.

  1. 서버:
    • mkdir project
    • git init
    • git add .
    • git commit #==> nothing to commit
  2. 온클라이언트:
    • RubyMine에서 새 프로젝트 만들기
    • 프로젝트의 최상위 디렉터리에 Git init
    • 변경사항을 서버에 푸시 #==> failed to push some refs to...

어떤 단계를 놓쳤습니까?

서버:

mkdir my_project.git
cd my_project.git
git --bare init

온클라이언트:

mkdir my_project
cd my_project
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push origin master

오리진을 추가할 때 사용할 수 있는 몇 가지 형식과 스키마가 있습니다.호스팅 서비스가 제공하는 기능을 확인해 보는 것이 좋습니다.

사용해 볼 수 있습니다.

서버:

새 그룹 추가/etc/group좋아요 (계속)

mygroup:1001:michael,nir

새 Git 저장소 만들기:

mkdir /srv/git
cd /srv/git
mkdir project_dir
cd project_dir
git --bare init (initial git repository )
chgrp -R mygroup objects/ refs/ (change owner of directory )
chmod -R g+w objects/ refs/ (give permission write)

클라이언트:

mkdir my_project
cd my_project
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push origin master

(고객 측에 대한 Josh Lindsey의 감사)

클라이언트 이후 서버에서 다음 명령을 수행합니다.

cd /srv/git/project_dir
chmod -R g+w objects/ refs/

git pull 후에 이 오류가 발생한 경우:

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details

git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream new origin/<branch>

시도:

git push -u origin master

도움이 될 겁니다.

커밋하기 전에 저장소에 하나 이상의 파일을 추가해야 합니다(예: .

프로젝트에 업스트림 분기가 없는 경우, 즉 원격 저장소가 로컬 저장소에 생성된 분기를 처음으로 알게 되는 경우 다음 명령이 작동합니다.

git push --set-upstream origin <branch-name>

@조시 린지는 이미 완벽하게 잘 대답했습니다.하지만 저는 ssh를 자주 사용하기 때문에 몇 가지 정보를 추가하고 싶습니다.

따라서 변경만 하면 됩니다.

git remote add origin youruser@yourserver.com:/path/to/my_project.git

대상:

git remote add origin ssh://youruser@yourserver.com/path/to/my_project

도메인과 경로 사이의 콜론은 더 이상 존재하지 않습니다.

클라이언트에 원격 리포지토리를 설정해야 합니다.

git remote add origin ssh://myserver.com/path/to/project

저는 문제를 해결할 수 있는 기존의 답이 있다는 것을 알고 있습니다.2021년 02월 11일 현재 git을 처음하시는 분들을 위해, 기본 branching git는"main"것은 아니다."master"branch, 명령은 다음과 같습니다.

git push -u origin main

로컬 Git repo가 있고 이 기존 repo에 오리진을 추가하려는 경우:

git remote add origin ssh://myserver.com/path/to/project
git pull origin main --allow-unrelated-histories
git push -u origin main

아래 명령으로 실행

git config --local -e

의 입력 변경

url = git@github.com:username/repo.git

로.

url = https://github.com/username/repo.git

@dangerous-dev에서 언급한 대로 사고가 발생하지만 다음과 같은 로컬 기본 분기가 있는 경우master라고 불리는 원격의 것.main다음을 사용하여 밀어넣기:

git push -u origin master:main

각각 긴 버전 사용:

git push --set-upstream origin master:main

언급URL : https://stackoverflow.com/questions/2337281/how-do-i-do-an-initial-push-to-a-remote-repository-with-git

반응형