Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
684 views
in Technique[技术] by (71.8m points)

github - How can I rollback a git repository to a specific commit?

My repo has 100 commits in it right now. I need to rollback the repository to commit 80, and remove all the subsequent ones.

Why?

This repo is supposed to be for merging from miscellaneous users. A bunch of merges went in as commits from me, due to excessive editing. That was due to a mislabeling of my remote branches, where 3 developers were labeled as each other. I need to reset to that point, and then pull forwards.

I wanted to rebase, as in this example: How can I remove a commit on GitHub?

However, git wants me to do a lot of conflict management. Is there a simpler way?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
git reset --hard <old-commit-id>
git push -f <remote-name> <branch-name>

Note: As written in comments below, Using this is dangerous in a collaborative environment: you're rewriting history


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...