简体   繁体   中英

Revert single file in pushed commit while contributing

I recently contributed in react native documentation and I forked the repo and then did 2 commits and I pushed it to my forked repo and then i merge it with their original repo. But i did one mistake i also pushed the yarn.lock file. Now They ask me to revert it.

"please revert the yarn.lock changes pushed in this PR"

"Like in other PR, please revert the yarn.lock changes and revert the link changes (which are already present in other PR), so the Readme.md will be the only changed file in this PR."

commit 0aaf169014833b32e835f50f11905afa0074fc71 (HEAD -> edit-branch-name, origin/edit-branch-name)
Author: bilal yaqoob <bilalyaqoob111996@gmail.com>
Date:   Sat Nov 27 08:13:10 2021 +0500

    edit branch name in readme

commit 681e334a04b4e0016203b191080f0e86af0f514f (origin/remove-empty-link, remove-empty-link)
Author: bilal yaqoob <bilalyaqoob111996@gmail.com>
Date:   Sat Nov 27 08:05:02 2021 +0500

    removed the empty link

How can i do this. As i am not very expert in git.

This is not difficult, but they are actually asking you to do two things, revert the change in yarn.lock and revert the removal of the empty link. Those are — or might be — two completely different sorts of action.

The empty link deletion is the result of a commit. Commits can be reverted:

git revert 681e334

So much for that; you've just made a new commit that undoes your first commit. Now look at yarn.lock . Is it back the way you found it? If not, you're going to have to find an earlier commit that contains the old state of yarn.lock , restore that, and make yet another commit:

git restore -s <goodCommit> -- yarn.lock
git add yarn.lock
git commit -m 'bring back old yarn.lock'

Now just push to append your new commit(s) to the existing pull request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM