문제

방금 git을 시작하고 질문이 있습니다. 내 앱에는 10 명의 다른 개발자가 작업하고 있으며 각 개발자는 Dev_xxxxx와 같은 자신의 지점이 있습니다. 그래서 저장소의 복제본을 작성하면 모든 코드가 내 컴퓨터에 복사됩니까? 이 경우 나는 그것을 원하지 않습니다. 내 지점이 dev_swamy라고 가정 해 봅니다. 그런 다음 어떻게 안정적인 지점과 dev_swamy를 복제합니까? 감사.

도움이 되었습니까?

해결책

기본적으로 git clone 모든 분기를 가져 오지만 해당 브랜치는 원격 트래킹 브랜치로 저장됩니다. 예를 들어 Branch 'dev_xxxxx'는 'origin/dev_xxxxx'로 저장됩니다 ( 'refs/remotes/origin/dev_xxxxx'는 전체 이름으로). 원격 트래킹 브랜치는 보이지 않을 것입니다 git branch 출력 : 필요할 것입니다 git branch -r 원격 추적 브랜치 (또는 git branch -a 모든 지점을 나열하려면). 해당 지점이 메인 라인에서 너무 많이 분기되지 않으면 저장소에서 너무 많은 디스크 공간을 가져 가지 않습니다. 그러므로 나는 당신이 왜 당신이 선택한 가지 만 복제하고 싶은지 모르겠습니다.

그럼에도 불구하고 두 개의 선택된 가지만으로 클론을 원한다면 다음과 같이 할 수 있습니다.

  1. 먼저 새 빈 저장소를 작성하십시오

    $ mkdir repoclone
    $ cd repoclone/
    $ git init
    Initialized empty Git repository in /home/user/repoclone/.git/
    
  2. 그런 다음 '원산지'라는 이름으로 저장소를 추가하십시오 ( "git clone"이 이름을 지정할 것입니다).git 리모컨"명령. 올바르게 추가되었는지 확인하십시오.

    $ git remote add -t master -t dev_swamy origin user@example.com:repo.git
    $ git remote 
    origin
    $ git remote show origin
    * remote origin
      Fetch URL: user@example.com:repo.git
      Push  URL: user@example.com:repo.git
      HEAD branch: master
      Remote branches:
        master          new (next fetch will store in remotes/origin)
        dev_swamy new (next fetch will store in remotes/origin)
    

    안정적인 분기가 '마스터'가 아닌 '안정'이라고 불리면 물론 위의 예를 수정해야합니다. 또한 있습니다 -m <branch> 옵션 지정된 분기가 원격에서 기본 브랜치가 되려면 옵션.

  3. '원산지'에서 가져 오기 (당신은 또한 사용하여 이것도 할 수 있습니다. -f 위의 "git remote add"옵션) :

    $ git fetch
    remote: Counting objects: 282, done.
    remote: Compressing objects: 100% (193/193), done.
    remote: Total 282 (delta 82), reused 0 (delta 0)
    Receiving objects: 100% (282/282), 81.30 KiB | 135 KiB/s, done.
    Resolving deltas: 100% (82/82), done.
    From user@example.com:repo.git
     * [new branch]      master     -> origin/master
     * [new branch]      dev_swamy -> origin/dev_swamy
    From user@example.com:repo.git
     * [new tag]         v1.0       -> v1.0
     * [new tag]         v1.0.1    -> v1.0.1
     * [new tag]         v1.1       -> v1.1
    
  4. "git clone"과 마찬가지로 '원산지/마스터'( '원산지/마스터'를 상류로 가져 가기 위해 현지 지점 '마스터'(작업을 수행 할 곳)를 설정하십시오.

    $ git checkout -t origin/master
    Branch master set up to track remote branch master from origin.
    Already on 'master'
    

    Branch 'dev_swamy'에 대해 이것을 반복 할 수 있습니다.

  5. 이제 구성 파일의 모습을 볼 수 있습니다. 편집하여 정확히 동일한 결과를 얻을 수 있습니다 .git/config 다음과 같이 보이도록 파일을 한 다음 "git fetch"를 수행합니다..

    $ cat .git/config  # or just open this file in your editor
    [core]
            repositoryformatversion = 0
            filemode = true
            bare = false
            logallrefupdates = true
    [remote "origin"]
            url = user@example.com:repo.git
            fetch = +refs/heads/master:refs/remotes/origin/master
            fetch = +refs/heads/dev_swamy:refs/remotes/origin/dev_swamy
    [branch "master"]
            remote = origin
            merge = refs/heads/master
    

저장소 작업을 시작하기 전에 GIT에 자신을 소개하는 것을 잊지 마십시오 (예 : 'user.name'및 'user.email'구성 변수; 일반적으로 USER PER-USER CONFIG 파일)!

다른 팁

복제 된 경우 모든 지점의 모든 개정판이 복제되지만 복제 된 저장소는 기본적으로 마스터를 확인합니다.

Git이 실제로 그렇게 일해야한다고 생각하지 않기 때문에 선택된 가지를 복용하는 것만으로도 까다 롭습니다. 가지를 수동으로 당겨야합니다.

mkdir repoclone
cd repoclone
git init
git remote add origin git://remote/url
git fetch origin master:master
git fetch origin dev_XXX:dev_XXX

위는 내가 잘 알고있는 것입니다. 그러나 정상적으로 작동하는 git repo를 설정하려면 원격 브랜치를 더 좁게 볼 수 있습니까? 당신은 그것을 쉽게 할 수 있습니다 :

mkdir repoclone
cd repoclone
git init
git remote add origin git://remote/url

# now open .git/config for editing in your editor
# replace the following line (grab all remote branches)
fetch = +refs/heads/*:refs/remotes/origin/*

# replace with lines listing exactly which branches you want
fetch = +refs/heads/master:refs/remotes/origin/master
fetch = +refs/heads/dev_XXX:refs/remotes/origin/dev_XXX

# save the file, now run

git fetch

이를 수행하는 또 다른 방법은 직접 복제를 피하는 것이지만 대신에 Fetch RefSpec의 사용자 정의 세트가있는 리모컨을 수동으로 추가하는 것입니다.

예를 들어

mkdir myclone
cd myclone
git init

git remote add origin url://origin.repo

# Add fetch rules for the branches that we want to track
git config remote.origin.fetch +refs/heads/master:+refs/remotes/origin/master
git config --add remote.origin.fetch +refs/heads/dev_swamy:+refs/remotes/origin/dev_swamy

# fetch now fetches just what we need, subsequently it will do incremental fetches
git fetch

# Creating local branches tracking the remote branches
git checkout -b master origin/master
git branch dev_swamy origin/dev/swamy

나는 여기서 더 중요한 질문은 다른 사람들이 당신이 복제하거나 당기는 것이 아니라 밀어 붙일 것이라고 생각합니다. 각 개발자가 자신의 지점에서 작업하고 있기 때문에 또 다른 질문은 공통 코드 기반으로 끝나는 방법입니다. 개발자가 지점을 마스터로 병합하고 있습니까? 그리고 그들은 변경된 마스터 브랜치를 중앙 저장소로 밀고 있습니까? 이 경우 어쨌든 다른 개발자의 지점을 당길 방법이 없습니다.

그렇지 않다면, 나는 당신이 어떻게 기능 팀을 구성 할 수 있는지 알지 못합니다.

그리고 마지막으로 생각했듯이 : 왜 다른 개발자의 지점을 저장소에 복제하고 싶지 않은지 궁금합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top