알고리즘 문제 푼다고 레파지토리가 엉망이여서 

하나로 합칠려고 시도했다. 

 

많은 시도가 있었지만 

그냥  git을 이해 못 했나보다 

 

어쨌든 시작해본다. 

 

합쳐서 저장할 레파지토리 만들기

 레파지토리를 새로 만들어준다. 

 

주소를 복사하거나 

저기 나와있는 주소를 복사한다. 

https://github.com/luster1031/Algorithm_Study.git

 

git을 켜준다. 

난 bash가 편해서 사용자에 들어가 git을 열어준다. 

물론 git은 깔려있어야 함

 

github로그인을 최초 설정한다. 

이건 내가 해서 캡쳐본은 없지만, 

이렇게 하면 된다. 

https://git-scm.com/book/ko/v2/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-Git-%EC%B5%9C%EC%B4%88-%EC%84%A4%EC%A0%95

 

Git - Git 최초 설정

Vim과 Emacs, Notepad++은 꽤 인기 있는 편집기로 개발자들이 즐겨 사용한다. Mac이나 Linux 같은 Unix 시스템, Windows 시스템에서 사용 가능하다. 여기서 소개하는 편집기들이 불편해서 다른 편집기를 사

git-scm.com

 

 

새로 만든 레파지토리 (합쳐서 넣을 곳)을 clone해준다

아까 복사한 주소를 넣어준다. 

 

 

원래 레파지토리 (합칠 것)도 clone해준다.

난 이 3개를 다 합칠 것이기 때문에,

3개를 전부 clone 했다. 

git clone https://github.com/luster1031/Algorithm.git
git clone https://github.com/luster1031/Basic.git
git clone https://github.com/luster1031/math.git

 

그럼 사용자에 clone한 레파지토리의 폴더가 생긴다.

 

 

저장한 곳으로 간다. (새로 만든 레파지토리)

cd Algorithm_Study

 

 

저장 할 것을 remote해준다. (복사할 대상)

git remote add copy1 ../Algorithm
git remote add copy2 ../math
git remote add copy3 ../Basic

 

 

fetch, merge해준다. 

아까 copy1, copy2, copy3을 다 해준다. 

여기서 빨간색 부분을 잘 보고 

merge 까지 해준다. 

copy1만 해보고 비워져있었던 저장할 파일 (Algorithm_Study)에 복사된 것을 볼 수 있다.

 

근데 하다보면 

copy2/main이 나오면

오류가 생기는데 

이건

git merge --allow-unrelated-histories [현재 브랜치와 같은 B의 브랜치 이름]

이라고 치면 된다. 

참고는 

https://velog.io/@lina0322/git-git-repository-%ED%95%A9%EC%B9%98%EA%B8%B0git-log-%EC%A7%80%ED%82%A4%EA%B8%B0

 

[git] git repository 합치기(git log 지키기)

안녕하세요. 엘림입니다🙇🏻‍♀️오늘은 repository끼리 merge한 과정을 정리해보았습니다. git fetch와 git merge를 이용하여, 저의 git commit log를 지켜보겠습니다!

velog.io

여기서 했다. 여기가 좋긴해요!~!~

 

그러고나서 딱 문제가

이런 모습이 보인다. 

 

  1. 먼저 i를 누르고
  2. esc누르고
  3. :wq누르고
  4. 엔터

https://velog.io/@ssmin0606/%EA%B0%9C%EB%B0%9C%ED%88%B4-Please-enter-a-commit-message-to-explain-why-this-merge-is-necessary-especially-if-it-merges-an-updated-upstream-into-a-topic-branch-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B0-git-bash

 

[개발툴] Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream in

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch

velog.io

 

 

 

네 이렇게 3개 다 하고

전 직접 파일을 바꿨어요

복사본은 절대 안 돼요!

옮겨서 했습니다. 그래야 log가 손상 안 돼요!

 

 

변경 상황을 이젠 git에 올려줍니다. 

꼭 Algorithm_Study(변경한 파일 안에서 해주세요!)

소스에 관한 설명은 아래를 참고하였습니다. 

https://coding-factory.tistory.com/244

 

[Git] Git 레파지토리 생성 & 소스 올리기 (Git Bash활용)

GitHub에서 원격저장소를 만든 뒤 Git Bash를 활용하여 Push하는 방법입니다. Git Repository생성 깃허브 바로가기 1. 위에 링크된 깃허브 사이트에가서 로그인을 합니다. (회원이 아니라면 회원가입을 해

coding-factory.tistory.com

 

git init
git status
git add .
git commit -m "algorithm merge files"
git remote add origin https://github.com/luster1031/Algorithm_Study.git
git remote -v
git push -u origin

git push origin master하니까 오류나서 

전 git push -u origin 했습니다. 

 

결과 : 잘 됐습니다!

 

+ Recent posts