![]() ![]() Not a great way to do this but if reset isn't working at all then maybe it's worth a shot. You should end up with a working dir that matches the desired commit. It isn't supposed to be used like this but you can create a new branch and revert all the commits between the most recent and the one you want (use the -no-commit option). You could consider trying git revert if reset isn't working. There's probably something wrong with your repo if you're resorting to hacky solutions like this, but if it works it works. If your HEAD is pointing where you want it, then replacing the files in your tree with the ones you downloaded should work. You'll get a zip with the files as they were in that commit. Click the "X commits" (leftmost button), navigate to the commit you want, click the name of the commit, click "Browse Files", "Clone or Download", and then download zip. But reverting is safer, and only add a new commit (instead of overriding the recent branch history). Issue the git revert command and provide the commit ID of interest. Locate the ID of the commit to revert with the git log or reflog command. The alternative would be to locally reset your branch to HEAD and force push, which can work if you are the only one using this branch. In review, the steps to git revert a commit and undo unwanted changes are the following. 3.git commit -m 'Restored file.txt to version abc1': this will commit your. On GitLab Web UI itself, the revert operation is documented here. 2.git checkout abc1 file.txt: this will bring your file to your wanted version. 1.git checkout file.txt: this will remove local changes, if you dont need them. Probably not recommended or safe but I've done it a number of times (consider backing up your local repo). Now say that I messed up something in the file file.txt and I want to go back to a previous commit abc1. If that failed, I would download the entire package from github at the specific commit you want and replace your working tree with those files. Is your goal to delete all the commits after "some fit & upd," or just get a working tree in that state? I'm assuming you tried git rest -hard 97f962f
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |