프로젝트를 하다보면 여러 파일들이 있는 폴더들을 github에 한꺼번에 올릴 때가 있다.
하나하나 파일들을 업로드 하는 것보다 한번에 github에 올리는 방법에 대해 알아보자!
1. 먼저 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
저는 Windows 64bit 다운로드했습니다.
2. Github에서 New repository를 만들어 주소를 복사한다.
3. 업로드 하고싶은 프로젝트 폴더를 우클릭 후 Git bash here 선택
4. 자신의 github 유저 이름과 유저 메일을 설정해준다.
Git bash 창에
git config --global user.name "유저이름"
git config --global user.email "유저 이메일"
입력
5. 이후 다음과 같은 순서로 작성!
git init //.git 파일 생성
git add . //선택한 프로젝트 폴더 내의 모든 파일 관리
git status //상태확인
git commit -m "주석" //커밋
6. 업로드 하기
git remote add origin [repository 주소]
git push -u origin master
※ 뒤쳐진 status 앞당기기
git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
2 commit behind 이므로,
git reset HEAD~<HOWEVER MANY COMMITS YOU WERE BEHIND>
git reset HEAD~2
※ Git ignore 활용하기
.gitignore 파일을 만들어 ignore하고 싶은 확장자명과 파일을 작성한다.
이후에 다음 코드를 작성하면 적용된다!
git rm -r --cached .
git add.
git commit -m "커밋메세지"
git push origin {브랜치명}
댓글