git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Update symlinks after changing core.symlinks
@ 2025-04-02  7:18 Andrej Zhilenkov
  2025-04-02 22:41 ` brian m. carlson
  0 siblings, 1 reply; 6+ messages in thread
From: Andrej Zhilenkov @ 2025-04-02  7:18 UTC (permalink / raw)
  To: git

Hello! Is there a direct way to update symlinks in repo after changing
core.symlinks?
E.g. update plain files, if it was false, with symlinks or vice versa.

I've tried `checkout` and `reset` but they have no effect in this case
(see the snippet below). The only two things that are working:
- checking out a commit before the symlink was introduced and then
checking out any commit after (need to know that special commit to
make it work for those specific symlinks, not practical)
- removing symlinked files and checking them out specifically (need to
either have a list or somehow search for those files to reset)

Is this the way to do it or is there an alternative?

Snippet output:
```
Using temporary directory: /tmp/tmp.gynGH2VcB1
Checking symlink status after creation:
lrwxrwxrwx 1 root root 12 Apr  2 07:12 symlink.txt -> original.txt
Checking symlink status after checkout:
lrwxrwxrwx 1 root root 12 Apr  2 07:12 symlink.txt -> original.txt
Checking symlink status after reset:
lrwxrwxrwx 1 root root 12 Apr  2 07:12 symlink.txt -> original.txt
Checking symlink status after removal and checkout:
-rw-r--r-- 1 root root 12 Apr  2 07:12 symlink.txt
```

Snippet:
```
%%shell
set -e

# Create a temporary directory
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
echo "Using temporary directory: $TMP_DIR"

# Initialize a new Git repository
git init -q
git config user.name "Test User"
git config user.email "test@example.com"

# Create and commit a regular file
echo "Hello World" > original.txt
git add original.txt
git commit -qm "Add original file"

# Add a symlink to the original file and commit
ln -s original.txt symlink.txt
git add symlink.txt
git commit -qm "Add symlink to original file"

echo "Checking symlink status after creation:"
ls -l symlink.txt

# Ensure core.symlinks is set to false
git config core.symlinks false

# Checkout just the symlink file from the master branch
git checkout -- symlink.txt
echo "Checking symlink status after checkout:"
ls -l symlink.txt

# Try resetting just the symlink file
git reset -- symlink.txt
echo "Checking symlink status after reset:"
ls -l symlink.txt

# Remove the symlink and re-checkout it
rm symlink.txt
echo "Checking symlink status after removal and checkout:"
git checkout -- symlink.txt
ls -l symlink.txt

# Cleanup
cd ..
rm -rf "$TMP_DIR"
```

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-10 19:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02  7:18 Update symlinks after changing core.symlinks Andrej Zhilenkov
2025-04-02 22:41 ` brian m. carlson
2025-04-03 22:25   ` brian m. carlson
2025-04-04  5:51     ` Andrej Zhilenkov
2025-04-04  7:31       ` brian m. carlson
2025-04-10 19:29         ` Andrej Zhilenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).