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
Mitchell Fargher11,634 Points
Using git practically
I am a bit confused with using git and github. The videos on how to use it were very helpful and the way they used it made sense, but I'm struggling with how to use it practically. Do you do your normal work INSIDE git like in the tutorials or do you work in your normal text editor and then just find the file inside of git and commit it.
This was confusing me sense they just showed it from inside of git and I really would prefer working in an editor (brackets) and pushing the file I created from there.
Jonathan GrieveTreehouse Moderator 91,252 Points
Yes this confused me a lot too. I'm sure there are some users who will chip in soon with the most basic commands that you will need but you are right.
- You initialise a local repository with your Git command line
- Git files track changes in your repository (or folder) behind the scenes
- You check the status of these changes regularly.
- You "stage" the files before commiting the changes.
- Commit early and commit often
- check a log of your comitts
There is so many cool things you can do with git. I love how with git you can go to a previous version of your files (so long as you have a commit for it) and go back and make some changes to your files. Once done you then move those changes to another "branch", knowing that your changes are save.
But to emphasize again you absolutely do save and work with your files in your editor as normal and then save (or commit) those changes in Git so you have a tracked version of those changes behind the scenes.
Kevin Korte28,148 Points
Sounds like you got it now Mitchell,
I was going to say, each new project you start, you would want to run
git init at the root of the projects folder. This sets up a new git project, and this git project will track everything in the folder alongside it where
git init was ran, as well as any new or additional files and folders you add inside this project.
From here, you can work in your text editor as usually, and git will quietly track everything that is new. Brand new files and folders will initially be untracked. Modified files and folders will be tracked, but changed. You can add all the changes, or you can add only some. Once files are added, you can commit them. All of this is done separate of Github. Git and Github are actually very separate. It's when you push them Github or Bitbucket is when you are making the changes available on the internet. Technically Git itself keeps everything stored on your local computer.
One more thing to note, there will be a time when you want to store secrets. Things people like me shouldn't be able to see, that your application needs. Passwords, API keys, etc. You wouldn't want to commit your username and password to your sendgrid account.
Usually, you store those secrets in a single file together, and load them as environment variables, or some other means. Than you use or create a file called
.gitignore in the root of your project, and add any files or folders that you don't want the internet to see. Anything in
.gitignore will be completely ignored by Git, and can't be checked in for a commit.