프로젝트 생성할 때 깃허브에 먼저 만들고 내려받는 경우도 있겠지만 로컬에서 먼저 프로젝트를 간편하게 만드는 방법들이 많기 때문에 로컬에 있는 프로젝트를 올리고 싶은 경우들이 많을 겁니다. 이런 방법들을 매일 검색해서 처리하다보니 방법도 조금씩 달라서 가장 하기 쉬운 방법을 찾아봤습니다.
깃허브에 올릴 프로젝트 생성!
먼저 로컬에 아무 프로젝트나 만듬.
D:\workspace>
D:\workspace>mkdir project-tmp
D:\workspace>cd project-tmp
D:\workspace\project-tmp>dir/w
D 드라이브의 볼륨: 새 볼륨
볼륨 일련 번호: F89F-63BC
D:\workspace\project-tmp 디렉터리
[.] [..]
0개 파일 0 바이트
2개 디렉터리 474,457,976,832 바이트 남음
뭔가 어떤 프로젝트 메이커를 이용해서 로컬 깃이 자동으로 생성되었다면 필요없지만 로컬 깃이 없는 경우 git init으로 깃을 시작해줍니다.
D:\workspace\project-tmp>git init
Initialized empty Git repository in D:/workspace/project-tmp/.git/
D:\workspace\project-tmp>
tmp.html 깃에 올릴 소스 파일 생성
tmp.html 이라고 대충 그럴듯한 파일도 만들어줍니다. 빈 파일이면 확인을 하기 힘드니까요.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
git status
git status를 입력해보면 아무 파일도 add가 되어있지 않죠.
D:\workspace\project-tmp>git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
tmp.html
nothing added to commit but untracked files present (use "git add" to track)
git add .
현재 경로에 있는 파일들을 모두 add.
D:\workspace\project-tmp>git add .
D:\workspace\project-tmp>git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: tmp.html
git commit -m "initial commit!"
커밋을 해줍니다.
D:\workspace\project-tmp>git commit -m "initial commit"
[master (root-commit) 1d503df] initial commit
1 file changed, 11 insertions(+)
create mode 100644 tmp.html
올릴 깃허브 프로젝트 생성~
project-tmp 라고 만들었습니다.
project-tmp 로 만들었습니다.
git remote add [주소.git]
올려야 하는 주소를 추가해줍니다.
D:\workspace\project-tmp>git remote add origin https://github.com/nhj7/project-tmp.git
D:\workspace\project-tmp>git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/nhj7/project-tmp.git'
D:\workspace\project-tmp>git push -u origin
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
D:\workspace\project-tmp>git push --set-upstream origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 356 bytes | 178.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/nhj7/project-tmp.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
이런식으로 failed 나오는데요. github에서 안내하는데로 하면요. 두번의 실패 사례가 있는데요. git push -u origin master나 main을 이용해서 원격지 깃허브에 푸시를 해주면 됩니다.
'dev' 카테고리의 다른 글
ftp, ftps, sftp(ssh) 개념 정리 (0) | 2021.07.26 |
---|---|
GitHub Copilot - AI 페어 프로그래머, 코딩을 자동으로? (2) | 2021.07.18 |
깃허브 액션(github action) 에서 젠킨스로 갈아탄 이유 (1) | 2021.04.26 |
vue.js vuetify data-table style overflow hidden not working (0) | 2021.04.23 |
UUID(범용 고유 식별자)와 RFC4122 (1) | 2021.03.26 |
UTF8과 AL32UTF8 차이점 비교 (0) | 2021.03.03 |
mariadb date, datetime 타입 default 현재 시간(curdate, current_timestamp, current_datetime) 설정 에러 (1) | 2021.01.17 |
자바스크립트 크롬의 불안정한 배열 정렬 문제 - Javascript chrome-v8 Unstable sorting problem (4) | 2020.11.26 |