我真的是github和git的初学者,我在我的github上有一些存储库,带有一些基本代码,最近我安装了一个新的操作系统备份我的应用程序代码并添加了很多东西,当我试图推动更改为github,我收到一个错误:
[rejected] master -> master (fetch first)
error: failed to push some refs to 'root@....git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
我在线搜索并找到了我执行的命令:
git pull --rebase
Run Code Online (Sandbox Code Playgroud)
这引起了另一个问题,我搜索并找到了另一个我执行的命令
git pull origin branchname --allow-unrelated-histories
Run Code Online (Sandbox Code Playgroud)
另一个错误显示,并找到我执行的另一个答案:
git fetch origin
git reset --hard origin/master
git pull
Run Code Online (Sandbox Code Playgroud)
这个删除了我在本地计算机上所做的所有更改,并将其替换为我在远程(github)存储库中的基本代码
对不起的家伙我知道无知不是祝福,但现在我问是否有办法让我的代码回来?
你用某种方式搞砸了HEAD
你的分支reset --hard
.使用reflog
找到最后提交你有你决定变基之前,然后重置该承诺.
git reflog -g
# find the commit id which you want to return to using the commit message
# It might contain two commit ids for the same commit message
# if rebase was successful. Choose the older one.
git checkout -b temp_branch
git reset --hard <found_commit_id>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
65 次 |
最近记录: |