Skip to main content
try to mention how git reset ties in here...
Source Link
rogerdpack
  • 67.7k
  • 40
  • 290
  • 409

You could use

git add -p <path> 

to stage the chunks that you want to keep in a particular file, then

git checkout -- <path> 

to discard the working tree changes that you didn't want to keep, by checking out the staged version of the file.

Finally, you can use

git reset -- <path> 

to revert the staged version of the file to the most recent committed version of the file to leave you with your changes unstaged (if you don't want to commit them).

You could use

git add -p <path> 

to stage the chunks that you want to keep in a particular file, then

git checkout -- <path> 

to discard the working tree changes that you didn't want to keep, by checking out the staged version of the file.

Finally, you can use

git reset -- <path> 

to revert the staged version of the file to the most recent committed version of the file to leave you with your changes unstaged.

You could use

git add -p <path> 

to stage the chunks that you want to keep in a particular file, then

git checkout -- <path> 

to discard the working tree changes that you didn't want to keep, by checking out the staged version of the file.

Finally, you can use

git reset -- <path> 

to revert the staged version of the file to the most recent committed version of the file to leave you with your changes unstaged (if you don't want to commit them).

Source Link
Lara Bailey
  • 801.5k
  • 110
  • 650
  • 667

You could use

git add -p <path> 

to stage the chunks that you want to keep in a particular file, then

git checkout -- <path> 

to discard the working tree changes that you didn't want to keep, by checking out the staged version of the file.

Finally, you can use

git reset -- <path> 

to revert the staged version of the file to the most recent committed version of the file to leave you with your changes unstaged.