min's devlog
[Github] Repository에 'main' branch로 push 하기 본문
Repository에 'main' branch로 push 하기
의도하지 않았는데도 Branch가 master로 올려지는 오류가 있었다.
깃허브 업로드 코드는 $ git push -u origin master 인데, 이렇게 하면 master 브랜치가 생성된다. 그래서 master 부분을 main으로 바꾸어봤는데 $ git push -u origin main 은 에러가 떴다.. 그래서 이걸 막게하기위해 결국 branch 자체의 이름을 바꿨다!
(이렇게 해도 오류가 생긴다면 포스팅 하단으로)
//초기설정
$ git config --global user.name "****"
$ git config --global user.name "****@gmail.com"
//로컬 깃 저장소 생성(.git 폴더 생성)
$ git init
//Working directory -> Staging Area
$ git add [directory]
$ git add .
//Staging Area -> repository(.git)
$ git commit -m "commit message"
//원격저장소와 연결
$ git remote add origin [원격저장소 주소]
//브랜치 명 바꾸기
$ git branch -M [branch name(main)]
$ git branch -m [현재 branch name] [바꾸고싶은 branch name]
//(선택) README.md가 있다면 : push 보다 pull 먼저
$ git pull origin [branch name(main)]
//로컬 레포지토리 -> 원격 레포지토리
$ git push -u origin [branch name(main)]
//파일 수정 및 추가 이후 : 다음번 commit & push
$ git pull origin [branch name]
$ git add [directory]
$ git commit -m "commit message"
$ git push -u origin [branch name]
git push origin main 오류
git push 과정에서 또 에러가 떠 폭풍 구글링을 했다..
찾아보니 원인은 .gitignore 파일 또는 README.md 파일로 인해 발생한다고 한다.
push하려고하는 브랜치 이름 앞에 + 를 붙여 push 하면 된다고 해서 해보니 성공!
'Error Note' 카테고리의 다른 글
[Github] fatal: protocol 'https' is not supported (0) | 2022.08.18 |
---|---|
[Spring] error : spring 404 (0) | 2022.08.09 |
[Java] java.lang.OutOfMemoryError (0) | 2022.07.28 |
[Spring] cvc-id.3: A field of identity constraint... (0) | 2022.07.26 |
[JSP] "javax.servlet.http.HttpServlet" was not found (0) | 2022.07.26 |
Comments