This blog will talk about:
- What Does git update-index –assume-unchanged <file> Do?
- How to Change Ignored File Status to “–no-assume-unchanged”?
What Does git update-index –assume-unchanged <file> Do?
To ignore the specific Git file, implement the below-given steps:
- Go to the Git repository.
- List current repository content.
- Select the desired file which needs to be ignored.
- Execute the “git update-index –assume-unchanged <dir/file-name>” command.
Step 1: Move to Git Repository
At first, switch to the specified path with the help of the “cd” command:
Step 2: List Repository Content
Now, display the existing content of the repository through the following command:
Here, we have selected the highlighted file name for further operation:
Step 3: Update File Index
Next, switch to the root directory and execute the “git update-index” command to update the index of the selected file:
In the above-stated command, the “–assume-unchanged” option is used for modifying the required file and “file1/file3.txt” is our desired file:
Step 4: Verification
After that, to verify whether the target file is ignored successfully or not, run the “git ls-files” command along with the “-v” option:
According to the below-given output, the “h” status beside the highlighted “file3.txt” name indicates that the index of this particular file has been ignored temporarily:
How to Change Ignored File Status to “–no-assume-unchanged”?
If you want to change the index value and do not assume the unchanged, then utilize the following command:
Here, the “–no-assume-unchanged” option is used to unset the status of the ignored file:
Run the following command to ensure the modified status of the ignored file:
In the below-provided output, the status of the ignored file has been changed to “H”:
That’s all! We have explained the method to ignore and unset the file status.
Conclusion
To ignore the specific Git file, first, move to the Git repository and list its content. Then, select the desired file which needs to be ignored and run the “git update-index –assume-unchanged <dir/file-name>” command. If you want to change a particular file status from ignored to default, execute the “git update-index –no-assume-unchanged <dir/file-name>” command. This blog illustrated the process of ignoring and unsetting the file status.