github에서는 자주 fork라는 단어를 접하게 된다.

하지만, git에는 fork라는 명령어가 없다. (이에 대해서는 그냥 고민만 있었다.)


문제의 발단은 github 외부의 repository(sourceforge.net)에서 github로 fork가 하고 싶어 졌다.

그래서, 그냥 local에서 clone하고, github에 새로운 repository만들고, push 했다.


이제, 궁금해 졌다.

1. fork와 clone의 차이

2. 외부 repository에서 github로 fork하는 방법


1. fork와 clone의 차이

결론부터 얘기하자면, fork는 clone과 동일한 작업이다.

stackoverflow의 두 개의 문서( Git-ForkingWithoutGithub, GitForkIsGitClone? )에서도, fork는 clone이다라고 설명한다. 또한 github의 내부 문서에서도, fork라는 작업은 clone을 포함한 일련의 작업이라고 설명되어 있다. (정확하게는 fork라는 것은 clone을 해서 기존의 프로젝트에 기여하기 위해 upstream등의 remote를 설정하고 fetch 등의 작업을 하기 위한 일련의 행위들로 설명한다.)

즉, fork라는 버튼만 놓고 보면 clone이라는 것이다.


2. 외부 repository에서 github로 fork하는 방법

github의 내부 문서(ImportingAnExternalGitRepository )에 설명이 나와 있다.

기본 작업내용만 옮겨보면 다음과 같다.

# In this example, we use an external account named extuser and
# a GitHub account named ghuser to transfer repo.git

git clone --bare https://githost.org/extuser/repo.git
# Make a bare clone of the external repository to a local directory

cd repo.git
git push --mirror https://github.com/ghuser/repo.git
# Push mirror to new GitHub repository

cd ..
rm -rf repo.git
# Remove temporary local repository

여기서 clone --bare옵션이나, push --mirror 옵션에 대해서는 좀 더 알아볼 필요가 있다.

또한, 처음에 내가 했던 방법과 어떤 차이가 있는 지도 나중에 확인해 볼 일이다.


* clone --bare

* push --mirror


+ Recent posts