git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Update symlinks after changing core.symlinks

From
AZAndrej Zhilenkov <azhilenkov@gmail.com>
Date
Apr 2, 2025, 07:18 UTC
Message-ID
<CAArAzAoU9qDj+yLi3pA6wFYdTAk0UvQk4omSWM1RL4D9w5fw_w@mail.gmail.com>

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" ```

Next: brian m. carlson
Message 1 of 6 in “Update symlinks after changing core.symlinks”
  1. Andrej ZhilenkovApr 2, 2025
  2. brian m. carlsonApr 2, 2025
  3. brian m. carlsonApr 3, 2025
  4. Andrej ZhilenkovApr 4, 2025
  5. brian m. carlsonApr 4, 2025
  6. Andrej ZhilenkovApr 10, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.