When finding and replacing across a large repository, I get a bunch of files with a typechange status. These are mostly symlinks.
Rather than
git checkout -- eachfile.name
Is there a way to reset only typechange files?
git reset --hard resets your index and reverts the tracked files back to state as they are in HEAD. It leaves untracked files alone. @fifigyuri -- correct.
Comparatively, git reset , moves both the HEAD and branch refs to the specified commit. In addition to updating the commit ref pointers, git reset will modify the state of the three trees. The ref pointer modification always happens and is an update to the third tree, the Commit tree.
It resets the index, but not the work tree. This means all your files are intact, but any differences between the original commit and the one you reset to will show up as local modifications (or untracked files) with git status.
git status | grep typechange | awk '{print $2}' | xargs git checkout
Flavor of the existing answer, but I prefer it:
git status --porcelain | awk '{if ($1=="T") print $2}' | xargs git checkout
--porcelain
is designed for this kind of use.
Note that this awk answer and the existing answer can be broken with filenames containing spaces, linefeeds, etc in which case we can use.
git status -z | perl -0 -ne 'print $1 if /^\s*T\s*(.+)$/s' | xargs -0 git checkout
git status -z
is the one really recommended for this kind of use and null terminates each entry. perl's -0
deals with that ,-ne
processes the given command for each line (or "entry" really). $1
refers to the first capture group here, which will include the file name and null terminator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With