본문 바로가기

Study/etc

GitHub 업로드 하기

728x90

1. Git을 설치한다.

 

https://git-scm.com/downloads

 

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

 

 

2. 내 GitHub 계정에 원하는 repository를 만든다.

New Repository 생성하기!

원하는 repository명을 입력하고 생성하면 된다.

 

 

 

생성 완료

 

 

3. 업로드하고자 하는 폴더를 우클릭하여 Git Bash를 한다.

 

프로젝트 폴더를 우클릭하고 Git Bash Here를 눌러준다.

 

 

 

git config --global user.name "유저이름"

git config --global user.email "유저 이메일"

따옴표 안에 본인 Git 유저명과 이메일을 입력하여 초기 세팅을 진행한다.

 

 

 

git init    // git 파일 생성한다

git add .   // 변경 내용을 스테이징 영역에 추가 / (. : 프로젝트 폴더 내의 모든 파일)

	// git add 파일이름.파일형식  ex) git add a.txt

git status   // 상태를 볼 수 있음

git commit -m "내용"   //커밋. 따옴표 안에 원하는 내용을 적어준다

 

 

 

 

git remote add origin https://github어쩌구.git		//위에서 생성한 repository 주소

git push -u origin master		//master 브랜치로 push

 

 

 

업로드 완료!!

 

 

 

 

 

+)

혹시 repository를 지웠다가 다시 만들었던가 할 때 push 에러 해결방법

 

브랜치 잘못 업로드해서 다시 하려고 하니까 이런 오류가 떴다

! [rejected] master -> master (fetch first) error: failed to push some refs to~

 

 

 

기존에 있던 데이터 손실을 막기 위해서 push를 못하게 하는거라 강제로 push해주면 된다

git push -u origin +master

+만 붙여서 push해주면 깔끔하게 다시 올라간다!

728x90
LIST