Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,439
Community Members
 
Community Events
184
Community Groups

How to add file into SourceTree Git but not track changes so file remains in repository

Edited

I am quite confused by the several subtle variations of the above question that result in a completely different thing being asked.

Basically I want to add a file into my repository so that whenever I clone my repository this file gets created. However, I do not want any changes to be tracked so basically Git will ignore the changes done to the file AFTER it has been committed into the repository the first time.

I want the file to exist in the repository so it is always created when I clone the repository but, it must not be deleted, but further any changes should be ignored.

How do I achieve this in SourceTree or directly in Git?

1 answer

0 votes
Rudy Holtkamp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 17, 2020

You can do it cmd line or in sourcetree, it does not matter. You need to add the file and add a .gitignore file. Then commit it and push it to the remote. Any changes down to the file are ignored by git. Unless you willingly add them.

So adding it into .gitignore will still allow it to remain in the repository?

ok, I just added the file into the gitignore list, however, it still shows up in the unstaged files list in sourcetree.

Using the  git status --ignored does not show it in the Ignored files list :|

The file is added into the repository so it is created when the repository is cloned. But, I want any further changes to be ignored. I don't know if an added file can be ignored using the .gitignore list.

Rudy Holtkamp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 17, 2020

Sorry I was mistaking, you need to execute the following command:

git update-index --assume-unchanged <file>

This will let git ignore the file locally.

Like Gyuunyuu likes this

Ok, and how do I know what files have this attribute applied to them?
Is it possible to do this from the SourceTree GUI?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events