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

Development Tools

Should I remove files from a git branch?

Hi everyone

I've created a repository using Git for a coffee shop website I'm working on. I'd already started working on the site before I did the git course so I added the "initial commit" files half-way through. I've decided to re-write one of the sections (the ACF loop isn't currently working and I don't like the look of the page) so I've created a new branch (drinks_rewrite). I made changes to a single file page-drinks.php and then used the git add * option which I thought would only add that file (since it was the only modified file) but it appears to have added all of the files again to the new branch.

You can see the project on GitHub here https://github.com/JamesPaskUK/lazydays

My question is, if I remove the unchanged files from the drinks_rewrite branch, will that be OK? I did a quick Google which suggests that if files are removed from branches but these are then merged back with master at a later stage, they'll be removed from master. I, however, was under the impression if they were in master but not in a branch, then git would simply ignore them (i.e. keep them in master), merge changed files and add new ones.

Is this not the case?

How should I have added files to the branch so that I only got the ones that had changed?

Hope someone can help. Forgive me if these seem like dumb questions.. this is my first attempt at a repository on my own.