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,553,525
Community Members
 
Community Events
184
Community Groups

How do tell Source Tree to ignore certain files?

I'm a new SourceTree (and GitHub) user.  For one of my repos I was able to specify that ceratin files were to be ignored  and not "checked in or pushed" to GitHub.  SourceTree honored my request.  I also indicated that this should apply to all projects and it looks like that request was also honored.  However, one of my specifications indicated all files under a certain folder, of course that folder has a different parent from project to project.  So, my question is (again I'm a new user) for my latest project that was added to GitHub, how do I specify to Source Tree that certain files should be ignored.  I'm not sure what state I have to get everything in in order for the ignore menuitem to become enabled.  Also, from SourceTree, how do I delete a folder from GitHub (w/o deleting the folder from my local project on disk)?

 

Thank you very much,

Phil

2 answers

1 accepted

17 votes
Answer accepted
Tim Crall
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 03, 2015

You can create a file called .gitignore within specific repos and list files (or patterns using *s) to be ignored.  This all that SourceTree is doing when you use that option, and it may be easier to just edit the file manually.  There is a lot of documentation out there on how to use .gitignore files.  You can put a .ignore file at the top level of the repo and/or in any individual folder within the repo.  The behavior inherits down.

Note that telling Git (SourceTree) to ignore a file does not remove that file from the repository if it has already been added.  In git you would do this with git rm --cached (if you want to remove the file from the repo but not remove it from the working directory).  In SourceTree, you can right-click on a file and select "Stop Tracking".

It's not really possible to delete a folder from a remote because that folder is present in whatever commits you've already pushed to the remote, and you can't remove a folder from a commit once its been committed.  You can stop tracking the folder locally (without deleting it from the working directory) and then it won't be present in your next commit.

 

Thanks for the detailed and clear response.

I'm looking at the .gitignore file created in my local repo of the project where I successfully indicated through SourceTree to ignore .class files and some other files and they were ignored. However, the .gitignore file is empty. I'm confused.

Tim Crall
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 04, 2015

If you checked the box for them to be ignored in all projects, the patterns would have been written to a .gitignore_global in your home directory.

Like Ray618 likes this

I did check that box, but can't find .gitignore_global anywhere on my local file system. What do you mean by home directory? Thanks.

Tim Crall
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 04, 2015

What kind of a computer are you working on? Windows or Mac?

Tim Crall
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 08, 2015

The home directory should be configured by your $HOME variable and is likely to be C:\users\username (at least that's how it is on my system). If you run Git Bash and type in "cd" with no arguments, it should take you there.

$HOME is defined as C:\Program Files (x86)\Git\etc but that Git folder doesn't exist. I found .gitconfig under c:\users\myUserName - bizarre!

BillyP
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 09, 2017

Git Bash in windows has gotten a lot better.  

Within Windows 10, you can run through Git Bash, all the normal git commands to get what you want.

git config --global core.excludesfile ~/.gitignore_global

You can also remove the '--global' to have it apply only to you current repo/ project.

git config core.excludesfile ~/.gitignore_global

the options is greyed out as well as stop tracking. When you add a gitnore to your repo its stuck in unstaged part and nothing seems to work

Look at your \.git\info\exclude

Makes anyone's life easier, especially if you work on a team with shared repositories.

Because.. .gitignore might be a good solution for you (for time being) but if someone (new in the future) is reading your ignore file will probably be confused about why certain files/paths are being excluded from the repository, and no one knows what implications removing them will have.

In my opinion,  \.git\info\exclude is the way to go

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events