본문 바로가기
IDE/GIT

https://stackoverflow.com/questions/18588974/git-prevents-pushing-after-amending-a-commit

by forkballpitch 2017. 7. 19.
반응형
git reset --mixed origin/master
git add .
git add -f * <-- 또는 이거사용
git commit -m "This is a new commit for what I originally planned to be an amendmend"
git push origin master -> 에러 

 [rejected] master -> master (fetch first)


git push origin master --force

try:

git fetch origin master
git merge origin master

After to wrote this code I received other error: (non-fast-forward)

I write this code:

git fetch origin master:tmp
git rebase tmp
git push origin HEAD:master
git branch -D tmp

And resolved my problem



rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git init

Reinitialized existing Git repository in C:/Users/rohyr/git/reactajax/.git/


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ touch Readme.txt


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git statis

git: 'statis' is not a git command. See 'git --help'.


Did you mean this?

        status


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git status

On branch master

Untracked files:

  (use "git add <file>..." to include in what will be committed)


        Readme.txt


nothing added to commit but untracked files present (use "git add" to track)


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git add Readme.txt


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git commit -m "Add Readme.txt"

[master c6f3a9c] Add Readme.txt

 1 file changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 Readme.txt


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git remote add origin https://github.com/forkballpitch/reactajax.git


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git remote -v


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git config --global user.name "forkballpitch"


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git config --global user.email "forkballpitch@gmail.com"


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git remote add origin https://github.com/forkballpitch/reactajax.git

fatal: remote origin already exists.


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git remote -v

heroku  https://git.heroku.com/reactjsajax.git (fetch)

heroku  https://git.heroku.com/reactjsajax.git (push)

origin  https://github.com/forkballpitch/reactajax.git (fetch)

origin  https://github.com/forkballpitch/reactajax.git (push)


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git clone  https://github.com/forkballpitch/reactajax.git

Cloning into 'reactajax'...

remote: Counting objects: 3, done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0

Unpacking objects: 100% (3/3), done.

Checking connectivity... done.


rohyr@rohyr-PC MINGW64 ~/git/reactajax (master)

$ git push origin master

To https://github.com/forkballpitch/reactajax.git

 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to 'https://github.com/forkballpitch/reactajax.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.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.



반응형

'IDE > GIT' 카테고리의 다른 글

git사용시 덮어씌우기  (0) 2022.03.18
github에 contribute 하기  (0) 2019.09.04
jira 설치하기  (0) 2019.01.10
github 폴더 커밋  (0) 2017.07.26
git 기초 퍼옴  (0) 2017.07.20