Home > Mobile >  Git - Change the file in one branch back to original in main
Git - Change the file in one branch back to original in main

Time:11-26

I'm new to git and have a package.json file in branch (let's call it branch1). I want to change this file back to the original one in the main branch.

I tried git checkout package.json main which didn't work.

CodePudding user response:

That's alright, git's hard! I believe you're looking for restore.

Restore specified paths in the working tree with some contents from a restore source. If a path is tracked but does not exist in the restore source, it will be removed to match the source.

Specifically try:

git restore --source main package.json

  • Related