After git reset returns the specified version, how to submit it to the server?
阿神
阿神 2017-06-05 11:08:52
0
3
914

The situation is like this:

I found an earlier submission today and just found that some files were deleted.

Now we want to return to the specified version commit:20a3725c

git reset --hard 20a3725c

Then re-git push failed, prompt:

To git@xxx/xxx.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@xxx/xxx.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.

Now we need to restore to version 20a3725c, how to solve it?

Another question is, can the originally deleted files be restored to the current version? (Because the current version has added or deleted some files (in other folders, not the same folder as the deleted files))

阿神
阿神

闭关修行中......

reply all(3)
淡淡烟草味

I haven’t thought of a solution yet.

(Back up the currently modified files first)

Best, return to the specified version first
git reset old_commit_id

Then, create a new branch
git branch -b rcommit_id

Next, delete the online master branch (switch the default branch to another branch)
git push origin:master

Then, overwrite the files in the current branch with the previously backed up files.
Finally, change the branch name to master, submit it again, and then set it as the default branch.

git branch -m rcommit_id master
git push origin master
小葫芦

It must be modified before it can be pushed. . .
If you just want to restore a certain version, you can use git revert to cancel that commit

为情所困

git revert '20a3725c
git push

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!