Sunday, May 12, 2024

Git - Skip-Worktree

If you have files that you don't want to commit then . . . 

Assumiing you have TortoiseGit installed.

Windows File Explorer > Right Click on File > Show More options > Properties > Git Tab > Check Skip-Worktree > Apply > Ok > F5 to Refresh Displayed Files

The skip-worktree flag in Git is used to tell Git to exclude a specific file from the working directory whenever possible. 

This means:

Git will avoid writing the file to the working directory during operations like checkout, pull, or switch.

Git won't track changes made to the file, even if it's present in the working directory.

Git won't record the absence of the file in commits.

This flag is useful for configuration files or other files that should not be accidentally committed but might need to be edited locally sometimes.

Here's a table summarizing the key differences between skip-worktree and the similar flag assume-unchanged:

Use Cases for skip-worktree

Configuration Files: You might have environment-specific configuration files in your Git repository that shouldn't be committed but need to be modified locally for development.

Third-party Libraries: Large libraries included in your project can be marked with skip-worktree to avoid cluttering your working directory and improve performance.

Things to Consider

skip-worktree requires some manual work compared to assume-unchanged. If you need to make changes to the file, you'll have to manually add it back to the working directory before editing.

skip-worktree doesn't work with all Git commands. For instance, stashing won't work on files with this flag.

I recommend checking out the Git documentation on git-update-index for more details on the skip-worktree flag https://git-scm.com/docs/git-update-index. There are also resources online that discuss using skip-worktree for specific scenarios, like managing configuration files.

Google Gemini

Resources:

How To Fix Gitignore Not Working - Kinsta®

Git – Problem with “skip-worktree” and Pull - CodeProject

Ignoring Files with Git | Automation Panda

Saturday, May 4, 2024

Git - Assume Unchanged

If you have files that you don't want to commit then . . . 

Assumiing you have TortoiseGit installed.

Windows File Explorer > Right Click on File > Show More options > Properties > Git Tab > Check Assume valid/unchanged > Apply > Ok > F5 to Refresh Displayed Files

Example

To undo Assume UnChanged . . . 

Windows File Explorer > Right Click on File > Show More options > Properties > Git Tab > UnCheck Assume valid/unchanged > Apply > Ok > F5 to Refresh Displayed Files

Resources: Ignoring Files with Git | Automation Panda

That's it !