- git error
Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g. 'git pull ...') before pushing again.
- Cause
First, I already had a remote origin.
$ git push -u origin main
To github.com:mellamonaranja/PrefixSpan.git
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'git@github.com:mellamonaranja/PrefixSpan.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
Second, the commits are defferent between exist remote origin(tree) and local tree. (Or there have been changes on the remote branch that you don’t have locally.)
$ git status
On branch main
Your branch and 'origin/main' have diverged,
and have 3 and 12 different commits each, respectively.#<<<<<<
(use "git pull" to merge the remote branch into yours)
Therefore it sent me back as "Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again." meaning I need to merge remote branto into local.
- Solution
Remove git.
#Linux or Mac
$ rm -rf .git/
# Windows
$ rm -r -fo .git/
And push again.
$ echo "# docker-compose_jupyternotebook" >> README.md
$ git init
Initialized empty Git repository in /Users/joohyunyoon/Documents/Workspace/.git/
$ git status
On branch master
$ git add .
$ git commit -m "edit files"
[master (root-commit) 8aef74f] edit files
6 files changed, 505 insertions(+)
...
$ git remote add origin git@github.com:mellamonaranja/docker-compose_jupyternotebook.git
$ git status
On branch master
nothing to commit, working tree clean
$ git push origin master
Counting objects: 9, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 4.59 KiB | 4.59 MiB/s, done.
Total 9 (delta 0), reused 0 (delta 0)
To github.com:mellamonaranja/docker-compose_jupyternotebook.git
* [new branch] master -> master
'Git' 카테고리의 다른 글
Add my code to my teammate's code using git branch (0) | 2022.07.12 |
---|---|
Push files to github with Personal access tokens (0) | 2022.06.15 |
git error : src refspec master does not match any (0) | 2022.06.15 |
git error : Permission denied (publickey) (0) | 2022.04.06 |
init, add, commit, checkout, branch, push, pull request, pull, logs, fetch (0) | 2021.06.13 |