Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Desmond Dallas
Desmond Dallas
6,985 Points

Github

HI all, I've set up a Github account. Ive come across a gitignore feature. Im first project will be to do a simple login form. I would like to know if I will need gitignore for this?

Also, Im looking for information on how to set up gitignore for visual studio on a mac and I cant seem to find any source for this. Can anyone help with the steps for me to set up a gitignore or somewhere where I can get more information on this as Im quite lost at this point. Thanks

3 Answers

dublinruncommutr
dublinruncommutr
5,944 Points

Hi Desmond,

.gitignore is just a text file that uses regular expressions to exclude from tracking based on matched patterns. You don't have to use it, but there are likely files you may not want to track.

For example, if you have a database or binaries or logfiles, you may wish to ignore the files or directories those files are in. Let's say you wanted to exclude all .txt files. You might add a line to this file with expression of *.txt

You can create a .gitgnore file in your favorite text editor/IDE or simply do the following from command-line:

>echo "*.txt" >> .gitignore

(appends *.txt to .gitignore file if it exists or creates it with this new expression in it)

The git website has some excellent instructions on syntax and creation: https://git-scm.com/docs/gitignore

Desmond Dallas
Desmond Dallas
6,985 Points

Great thanks for the information. I was actually watching a youtube video, where the guy basically copied and paste a long list of code. Guess this would ignore all that is necessary:

https://stackoverflow.com/questions/2143956/gitignore-for-visual-studio-projects-and-solutions

Just concerned as I don't want to be sharing anything I shouldn't. Is there a single setting you can make for future documents you may want to ignore. Hence the list in the link provided. However, I guess I have to take little steps as its way beyond me for now.

Thanks for the reply

Desmond Dallas
Desmond Dallas
6,985 Points

Thanks for the info, much appreciated

dublinruncommutr
dublinruncommutr
5,944 Points

Hi Desmond - good concerns around git and adopting best practice. I'll admit I'm a bit out of my depth with regards to the Visual Studio IDE.

As far as not sharing do you have some context? I probably would be more concerned with inadvertently excluding something that another collaborator might need for a pull request to create a properly functioning environment.

It sounds like you're on the right path and asking the right questions - if you do settle on a boilerplate list of .gitignore exclusions, make sure you understand what they do and why they're there.

Cheers!

Desmond Dallas
Desmond Dallas
6,985 Points

Thanks for the advice. Im about to start a long term project but have not as yet shared any files.

Desmond Dallas
Desmond Dallas
6,985 Points

Thanks for the advice. Im about to start a long term project but have not as yet shared any files.