[Git] git push시 에러 해결 방법 - error: failed to push some refs to 'github.com:username/repository.git'

민지·2021년 11월 5일
1

Git

목록 보기
1/4

repository에 있는 프로젝트를 깃허브로 push 할 때 에러 메세지가 뜨는 경우가 발생한다.

해당 에러는 깃허브에서 pull 없이 push할 경우 기존 내용을 삭제하는 문제가 생길 수 있기 때문에 이런 문제를 피하고자 에러 메세지를 발생시키는 것이다.

이는 repository에 commits한 내용이 없기때문에 server에 추가할 branch 또한 존재하지 않아 발생한 에러이다. (repository가 비어있음)

git init

git add .

git commit -m "메세지"

git config user.name "Username"

git config user.email "Email address"

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

git push -u origin master

이미 올라간 프로젝트에 새로운 내용을 추가해서 업데이트가 필요하다면

git add .

git commit -m "메세지"

git push origin master

이렇게 하면 push가 된다고 하는데 안된다.

master가 main으로 바뀌었다고 한다.
git push origin main으로 해보니까 리모트로 드디어 보내졌다.

profile
개발일지

0개의 댓글