@w1024020103
2017-02-16T17:21:11.000000Z
字数 1748
阅读 2685
未分类
$ git push origin master
[rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/w1024020103/cs61b.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.
I tried to pull everything from skeleton:
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
I searched the webs and finally found this method in this site helpful:
高效使用Git
I first check out the git status
, and it were like this:
So it seems I haven't commit my changes, I used git commit -am"message"
(同 git commit -a 只是不启动文本编辑器) to commit them all and then I did git push origin master
, I pushed things in my github, but unfortunately wrong place!
I put them there....while they should be in folder proj1a.
Then I deleted those files which were pushed to the wrong place, but this was actually not a safe thing to do! I lost them all in my local files, luckily I have them in my Sublime_Text!
NOTE: do not delete files in your github sites casually coz you might lose them locally!!!
Be sure to save all your stuff in another folder that are not related to your github.
I used git status
. and things look weird:
I then pulled things from github using git pull origin master
, and checked out git status
again, those red signs turned green.( dunno why )
Then, I used routine things like git add
and git commit -m""
,
But, strange and sad, my folders and files are gone and only left with these newly commited files in my github site!
NOTE: cd to cs61b ALWAYS, do not cd to proj1a or other folders.
I then used git commit -am"message"
and git add .
git pull origin master
git push origin master
for multiple times, working things out.
Things finally worked out, I have to save all my things in anoter place in case I delete things unintentionlly.