Git 사용법

Git 사용법

1. https://github.com/

깃허브에 접속 > 로그인 > repostiry 생성

 

GitHub: Where the world builds software

GitHub is where over 83 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...

github.com

 

2. https://git-scm.com/downloads

git 다운로드

 

Git - Downloads

Downloads macOS Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific exp

git-scm.com

 

3. git bash - 환경설정

 

git bash를 열고 명령어 입력 

 

git config --global user.name "Username"

: username 입력

 

git config --global user.email "Email"

: git을 가입한 email 입력

 

git config --list 

: 설정 확인(name, email 확인)

 

4. 프로젝트에서 Terminal 열기

5. git init : git 초기화 (git 준비)

6. git add . : 파일 추가 (.은 모든파일)

7. git status :  상태확인, add 명령어로 추가할 파일 확인 가능 (필수X)

8. git commit -m "first commit" : 히스토리 만들기

9. git remote add origin https://github.com/shimdy1013/Blog-Management.git
: 지정된 저장소에 추가

10. git remote -v : 연결상태 확인 (필수X)

11. git push origin master : 파일 전송

 

에러1)

error : src refspec master does not match any 에러 해결 방법

  • 해당 에러는 깃허브에서 pull 없이 push할 경우 기존 내용을 삭제하거나 하는 문제가 생길 수 있기 때문에, 이런 문제를 피하고자 에러 메세지를 발생시키는 것
  • 새로운 Git Repository를 init하고, 다시 push 해야한다.

1. git init


2. git add .


3. git commit -m "message"
: 다음과 같은 순서로 이름과 이메일을 입력 후 다시 Push하면 문제없이 Git에 업데이트 완료


4. git config user.name "Username"


5. git config user.email "Email address"


6. git remote add origin "github.com/your-repo.git"


7. git push -u origin master

 

 

만약 master 브랜치가 없어서 발생하는 오류라면
1. git checkout -b 'master'
2. git push origin master

 

 

이후 새로운 내용이 추가되거나 수정되었을 때 

1. git add . (또는 특정 파일이나 폴더)


2. git commit -m "message"


3. git push -u origin master

 

 

에러 2)

현재 브랜치의 끝이 리모트 브랜치보다 뒤에 있으므로 업데이트가 거부되었습니다

 

해결방법

https://medium.com/@yms0214/git-%EB%AC%B8%EC%A0%9C-%ED%98%84%EC%9E%AC-%EB%B8%8C%EB%9E%9C%EC%B9%98%EC%9D%98-%EB%81%9D%EC%9D%B4-%EB%A6%AC%EB%AA%A8%ED%8A%B8-%EB%B8%8C%EB%9E%9C%EC%B9%98%EB%B3%B4%EB%8B%A4-%EB%92%A4%EC%97%90-%EC%9E%88%EC%9C%BC%EB%AF%80%EB%A1%9C-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%EA%B0%80-%EA%B1%B0%EB%B6%80%EB%90%98%EC%97%88%EC%8A%B5%EB%8B%88%EB%8B%A4-1b4cdf80c2f

 

Xcode에서 Git 사용

https://keepmind.net/xcode%EC%97%90%EC%84%9C-git-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0/

 

[Git] 6. Xcode에서 Git 사용하기 | KEEPMIND

안녕하세요, 오늘은 Xcode에서 Git을 사용하는 방법을 소개해드리도록 하겠습니다. Xcode는 macOS의 IDE (Integrated Development Environment ; 통합개발도구) 입니다. Windows에서는 공식적인 C 컴파일러가 존재하

keepmind.net