반응형

프로젝트 fork 후 원격저장소의 변경 사항을 로컬 브랜치에 머지하기(로컬에 머지 및 로컬에 연결된 원격 master에도 동시 반영)

우선, 원격 저장소의 이름들을 확인한다.

git remote -v

origin만 있고 upstream은 없을 것이다.
원격 저장소 목록에 upstream을 만들어준다.

git remote -v add upstream 원격지주소

다시, "git remote -v" 로 확인해 보면, fetch/push로 각 2개의 원격 저장소를 바라보고 있는 것을 확인할 수 있다.

upstream 레파지토리에서 최신사항이 있는지 "git fetch upstream"으로 확인 가능 하다.
merge 수행을 위해 현재 브랜치를 master 로 이동한다("git checkout master").

upstream의 변경사항을 로컬 master로 가져와 병합(Merge)한다.

git merge upstream/master

"git log" 명령으로 커밋 히스토리를 출력해 반영사항을 확인할 수 있다.

※ 로컬에 git clone을 새로 한 경우 원격저장소 목록에 upstream 없다. 새로 만들어줘야 한다.

더보기

참고한 사이트)
- nochoco-lee.tistory.com/6?category=343045
- youngjinmo.github.io/2019/09/git-sync-forked-repo/#mergeupstream
- wedul.site/463
검색 키워드)
: git fork 후 pull

 

반응형
반응형

git 사용시 히스토리에 노트를 추가 할 때가 있다.
다른 장치에서 git clone 해보면 노트는 받아 올 수 가 없다.
입력한 노트를 서버에 반영하고 또한 받아 오기 위해서는 아래 명령을 이용 한다.

*서버에 노트 보내기

git push <remote> refs/notes/*

*서버에서 노트 받아오기

git fetch origin refs/notes/*:refs/notes/*

! 검색 키워드: git memo note push

반응형
반응형

비공개 저장소 기여 반영하기 팁 입니다.

잔디 화면에서 우측 설정 버튼을 누르면, Private contributions 항목이 있는데 이를 체크 해주면, 깃헙 비공개 저장소에서 작업한 내역을 깃헙 잔디에 반영이 됩니다. 단, 이렇게 하면 비공개 저장소에서 작업한 내역이 공개된 잔디에 표시되고, 권한이 없는 사람에게는 컨트리 뷰션 활동의 상세 내용이 숨겨진 채로 표시 됩니다.

반응형
반응형

로컬 폴더에서 ssh key 생성

ssh-keygen -t rsa -b 4096 -C "id@gmail.com"

github Settings Deploy keys 에서  add deploy key 클릭
.pub 파일 내용 복사해서 Key 부분에 붙여넣은 후 Add key 클릭

터미널 에이전트에 ssh key 등록

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/key_id

 SSL certificate problem: self signed certificate in certificate chain
 발생시.

git config --global http.sslVerify false

git clone  수행

 git clone https://github.com/ID/REPOSITORY

매번 설정 하고 사용이 번거롭습니다.
현재는 GitHub Desktop 프로그램을 사용하는 것으로 함.
GitHub Desktop 프로그램 사용시 push 후 아래 오류 발생시 조치 방법.

더보기

github desktop channel next initializesecuritycontext

git config --global http.sslVerify false
반응형
반응형

git 사용시 파일을 등록(add) 하고 커밋(commit) 후 푸쉬(push) 하는 과정은 명령어가 익숙하지 않은 상태에서는 어려울 수 있습니다.

윈도우 환경에서 tortoise 도구는 명령 방식대신 GUI 프로그램을 활용하게 하여 git 사용에 도움을 받을 수 있습니다.
이 tortoise 프로그램과 커맨드 방식을 조합해서 조금 쉽게 깃허브를 사용하는 방법을 구성해 봅니다.

(PC에 git과 tortoisegit이 설치된 상태를 전제로 합니다.)
1. 깃허브에서 저장소를 생성
깃허브 헬프 페이지를 참고해서 init 수행
2. 로컬 컴퓨터에 폴더를 생성
3. 깃허브 관리페이지를 참고 SSH keys 생성 및 등록
4. 로컬 컴퓨터에 생성한 폴더에서 Git Bash Here 실행 후 생성한 SSH key 등록 
깃허브 헬프 페이지를 참고(링크)
5. 소스 파일 작업 후 tortoisegit 을 이용해 파일 등록 및 커밋 수행.
또는 커맨드 명령을 이용:
깃허브 헬프 페이지를 참고(링크)
6. Git Bash Here 에서 git push 수행

$ git push origin your-branch

 

반응형
반응형

< trouble shooting & note >
- Push  해서 오류 나는 것들은 오류 메시지에 따라 오류 fix 합니다.
- 기본적으로 ignore 리스트는 정리를 해두고 수행하는 게 좋습니다. Ignore도 add해서 활용 하는 것 확인이 필요합니다.
windows git insufficient permission for adding
서버 저장소 권한 설정을 바꾸거나 C드라이브가 아닌 다른 드라이브로 변경 설정 합니다.
- tortoise git 사용시 git clone 후 "git clone  SSL certificate problem: self signed certificate in certificate chain" 오류가 발생할 경우 Tortoise git 셋팅 에서 git 카테고리 'Edit systemwide gitconfig' 에서 [http] 탭에 sslVerify = false 를 추가 후 실행.
다른 PC에서 git repository 셋팅 PC  push가 안될 때, 확인 사항
Bitvise SSH Server 설정 확인

- 다른 PC에서 git repository 셋팅 PC 에 push가 아래와 같은 메시지로 되지 않을 때, 
remote: error: insufficient permission for adding an object to repository database ./objects 
remote: fatal: failed to write object 
error: unpack failed: unpack-objects abnormal exit 

아래와 같이 공유 폴더 권한 설정을 한다.

 - git push 후 아래 에러 메시지를 확인 합니다. 
~ ~ ~ ~ ~ 
fatal: 'origin' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 
~ ~ ~ ~ ~ 
원격지의 git 서버 폴더 권한 문제로 발생 합니다. 
해당 폴더의 권한을 모두 허용으로 바꿔주고, '읽기 전용'을 해제 적용 합니다. 
git push를 다시 시도 하여 Success를 확인 합니다.

- Git push 후 아래 에러 메시지 발생.

(Case1)

더보기

git.exe push --progress "origin" master

 

Counting objects: 7, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (3/3), done.

Writing objects: 100% (7/7), 1.22 KiB | 0 bytes/s, done.

Total 7 (delta 1), reused 0 (delta 0)

remote: error: refusing to update checked out branch: refs/heads/master

remote: error: By default, updating the current branch in a non-bare repository

remote: error: is denied, because it will make the index and work tree inconsistent

remote: error: with what you pushed, and will require 'git reset --hard' to match

remote: error: the work tree to HEAD.

remote: error:

remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you

remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.

remote: error:

remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

To //…

! [remote rejected] master -> master (branch is currently checked out)

error: failed to push some refs to '…'

 

git did not exit cleanly (exit code 1) (765 ms @ 2019-11-04 오후 4:43:06)

(Case2)

더보기

git.exe push --progress "origin" master

 

Counting objects: 61, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (61/61), done.

Writing objects: 100% (61/61), 1.10 MiB | 380.00 KiB/s, done.

Total 61 (delta 52), reused 0 (delta 0)

remote: error: refusing to update checked out branch: refs/heads/master

remote: error: By default, updating the current branch in a non-bare repository

remote: error: is denied, because it will make the index and work tree inconsistent

remote: error: with what you pushed, and will require 'git reset --hard' to match

remote: error: the work tree to HEAD.

remote: error:

remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you

remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.

remote: error:

remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

To …

! [remote rejected] master -> master (branch is currently checked out)

error: failed to push some refs to '… '

 

git did not exit cleanly (exit code 1) (4103 ms @ 2019-11-05 오전 11:36:40)

 *서버쪽에 아래와 같이 조치

git config --bool core.bare true

(아래 시도 )

git reset --hard

git init --bare

클라이언트 쪽에서 아래와 같이 체크 (체크하지 않아도 ) 다시 push 수행

Push 성공됨을 확인.

 

반응형
반응형

[ 윈도우 git server 셋팅(인트라넷 셋팅 가능) ]
* 서버쪽
1. SSH 통신을 위해 Bitvise SSH Server 프로그램 설치 합니다.
2. Control Panel의 Server 탭의 Settings에 Open easy settings 클릭 합니다.
3. Windows accounts에 Add해서 'Local account' 등록 합니다.
* 클라이언트쪽
1. 탐색기로 \\서버IP로 등록한 계정으로 연결 후 tortoise git 사용 시작 합니다.
* 클라이언트쪽-인트라넷
1. Git Clone 실행 합니다.
2. URL에 \\서버 아이피\경로 입력 합니다.
3. Directory에 자동 입력된 로컬 폴더 확인 후 'OK'클릭 합니다.

[ NAS git server 셋팅 ]
* 서버쪽
..
* 클라이언트쪽-윈도우
1. TortoiseGit 설치 후 Git Clone 수행 합니다.
2. Clone Existing Repository URL에 아래 형식으로 URL 입력 합니다.
예시)
ssh://계정@서버 아이피 및 도메인:포트번호/var/services/homes/계정/repo/세부 폴더

[ NAS 서버를 사용한 경우 서버쪽 셋팅 ]
* 보안을 위해 SSH 포트를 변경한 경우. 허브 포트포워딩을 설정.

* 허브 설정 (KT 공유기 기준)
외부포트 : 변경 포트
내부 IP 주소 : Git 설정 서버 아이피
내부포트 : 변경 포트
프로토콜 : ALL(TCP, UDP)
설명 : 입력..

[ SourceTree/tortoiseGit & NAS Git ]
< 맥 sourceTree (새탭 만들고 )/ 윈도우 tortoise 에서 '클론' 수행 >
(서버에 ssh 접속해서 리포지토리 생성)
ssh -p 포트번호 계정@도메인
mkdir 폴더명 < 리포지토리 생성
cd 폴더명
git init --bare < 초기화
cd ..
chown -R 계정명:users 폴더명 < 권한 (해당 계정으로 로긴해서 만들면 필요 없음)
SourceTree 에서 로컬 탭 누르고, 새로 만들기 -> URL 에서 복제 선택
ssh://계정명@도메인:포트번호/경로 입력 후 목적지 경로 확인. '클론' 클릭.
ex) ssh://계정명@도메인:포트번호/var/services/homes/계정명/repo/폴더명

(서버 윈도우, 인트라 네트워크 망 윈도우간 통신에서는 먼저 '\\아이피 주소' 접속을 먼저 해주고 git 명령 수행(pull, push, ...)
URL: "\\아이피 주소\c\repo"
Directory: "C:\repo"
(서버 윈도우, C 아래 폴더 push 때 권한 오류 있어서 F로 옮기고 폴더공유 및 권한 모든 권한으로 설정.)
: 서버 쪽으로 push 문제 없음.
(서버 윈도우, Git Push error: refusing to update checked out branch 에러가 뜨는데, 윈도우 해당 폴더에서 아래 명령 수행해줘야함)
git config --bool core.bare true
(서버 윈도우, tortoise 
fatal: This operation must be run in a work tree 문제)
git config --unset core.bare

< git repository를 다른 컴퓨터로 가져와 별도 서버에 push 해버리기 >
1. 폴더 통째로 다른 컴퓨터로 복사해 오기.
2. 우클릭 TortoiseGit -> Settings
3. remotURL 부분에 ssh://계정명@도메인:포트번호/var/services/homes/계정명/폴더 경로
4. Push 수행
5. 또 다른 컴퓨터에서 Git Clone 수행으로 해당 repository 가져오면 그대로 보존 되어 있는 repository를 가져와 볼 수 있음.

< git 서버로 사용할 윈도우(7) PC 설정 >
- Bitvise SSH Server 프로그램 설치(Account 등록 하기)
- 서버 쪽 폴더 접근 에러가 날 경우 서버쪽 repository 경로가 c드라이브가 아닌 위치로 이동 설정을 하거나 폴더 접근 권한 수정을 해줍니다.

< 사용 노트 : 작업 싱크 원칙 >
= 클라이언트->서버
commit 눌러보고 작업한거 있는지 먼저 확인 처리.

(클라이언트 쪽)
revert 확인 -> pull
working -> commit -> push

(서버 쪽)
revert
= 서버->클라이언트
 commit 눌러보고 작업한거 있는 먼저 확인 처리.

(서버 쪽)
working -> commit

(클라이언트 쪽)
revert -> pull

반응형
반응형

< 윈도우(Windows) 환경에서 소스 버전 관리 툴인 시(Git)을 설치 하는 방법 >
1. Git 다운로드
https://git-scm.com/ 에 접속해서 다운로드 페이지에서 설치파일을 다운 받습니다.
2. Git 설치
다운 받은 설치 파일(Git-2.16.2-64-bit.exe)을 실행해서 설치 합니다.
Adjusting your PATH environment 에서 Use Git from the windows Command Prompt를 선택하여 cmd 에서도 Git 명령어를 사용할 수 있도록 합니다.
3. Git 버전 확인
Git 설치가 완료되면 Git bash 또는 CMD 명령창을 열어 git --version 명령어를 입력하면 버전이 표시됩니다. 정상적으로 버전이 표시되었다면 Git 이 설치완료 됩니다.

< TortoiseGit을 이용하여 저장소(repository) 클론(clone)해서 사용하기>
※ TortoiseGit 설치 후 아래 Name, Email을 기입하고 확인을 누른다.


1. 해당 폴더 위치에서 마우스 우클릭 으로 Git Clone 선택 합니다.
2. Git clone - TortoiseGit에서 URL, Directory 확인 후 OK 선택 합니다.
3. 계정 비밀번호를 묻는 창이 뜨면, 비밀번호 입력 후 OK 선택 합니다.
*URL 형태
ssh://계정@도메인:포트번호/var/services/homes/계정/폴더1/폴더2
*Directory 형태
C:\폴더A\폴더B

< 네트워크 보안을 위해 SSH 포트 번호를 서버설정에서 변경 후 외부에서 TortoiseGit 사용하기 >
아래 화면과 같이 해당 폴더위치로 이동 후 TortoiseGit 셋팅 메뉴에서 아래와 같이 도메인과 경로 사이에 ':포트번호'를 입력해 줍니다.

ssh://계정@도메인:포트번호/경로

< 기존 repository를 다른 PC에 옮기고 새로운 클라이언트 PC에서 clone해 오는 과정 >
1. .git을 포함 하고 있는 폴더 전체를 다른 PC에 복사 합니다.
2. Tortoise Git 에서 Git Clone 실행 합니다.
3. Clone Existing Repository의 URL에 아래 경로를 입력 합니다.
\\아이피\드라이브명\경로
Clone Existing Repository의 Directory에는 아래와 같이 자동으로 경로가 들어갑니다.
드라이브명:\경로
'OK' 버튼을 누른다.

반응형

+ Recent posts