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?
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 status | grep typechange | awk '{print $2}' | xargs git checkout
awk '{print $3}'
otherwise it wasn't getting the filename. git status | grep typechange | awk '{print $3}'|xargs git checkout
–
Centrist git status | grep typechange | cut -d' ' -f2- | xargs -d'\n' git checkout
–
Tithe 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.
In most times its better to remove symlinks from your repository. If you work under different operating systems its a problem to have the links in your repository.
When you remove it and set it to a new location your file is modified.
Some Java Git client have problems with symlinks. They try to follow them and you get an error. I had this problem with the Jenkins client.
To add all symlinks to the .gitignore
you can run the following command under Linux
find /your/directory -type l >> .gitignore
© 2022 - 2024 — McMap. All rights reserved.
git config core.symlinks true
helped me with Sourcetree automatically marking checked out files as modified. Setting symlinks to true, resolved the issue. – Longspur