我成功的恢复了以前删除的问题
git log
git reset 424a74fba6fbf6ad53e59e7d579427b7acdfde
git checkout 424a74fba6fbf6ad53e59e7d579427b7acdfde file_name
随后增加了几个文件,再进行推送git push
发现了问题
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxxx/xxxx.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.
我根据输出,git pull 一下
git pull https://github.com/xxxx/xxxx.git
然后再次git push,这次push成功了,但是那个找回来的文件又会消失。
如何在本地恢复找回的文件后,下次再git push的时候,这个被恢复的文件成功上传到仓库,而不是默认消失来处理?
按照乔治的说法,来做,有新情况出现,因为这期间,我本地又编辑了几个新文件
git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: source/os/上网设置.rst
Untracked files:
(use "git add <file>..." to include in what will be committed)
source/github/git命令行正确显示中文.rst
no changes added to commit (use "git add" and/or "git commit -a")
如果直接pull:
git pull --rebase
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.
我直接 git push ,出现的结果
source/github/git命令行正确显示中文.rst 这个文件没有推送,
但是
From https://github.com/xxxx/xxxx
* branch HEAD -> FETCH_HEAD
Removing source/os/白名单.rst
白名单这个文件还是删除了!
现在越搞越乱了
git stash
other/.bashrc: needs merge
看看
git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
new file: source/github/找出删除的文件.rst
deleted: source/os/白名单.rst
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: other/.bashrc
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: source/os/上网设置.rst
Untracked files:
(use "git add <file>..." to include in what will be committed)
source/github/git命令行正确显示中文.rst
commit一下
git commit
U other/.bashrc
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.