Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any reason I should be working out of a branch in Git if I'm a lone developer? [closed]

Tags:

git

I just started using Git recently and I was reading up on Git best practices and it seems the most common one is to never work out of your master branch, always create a separate branch and work out of that. I'm wondering if this is only true when working with other developers or if this is something I should be doing if I'm the only developer on the project. If so, why? And how often should I merge the new branch? Why is that any different than just working out of the master branch and committing changes when necessary?

Thanks so much for your wisdom!

like image 1000
BeachRunnerFred Avatar asked Oct 26 '10 18:10

BeachRunnerFred


People also ask

What happens if you make a change on a branch you don't own?

When you change a file in your work-tree, nothing happens to the copy in the index. It still matches the copy in the commit you chose. You have to run git add to copy the file from the work-tree, to the index.

When should I use branches in git?

In Git, branches are a part of your everyday development process. Git branches are effectively a pointer to a snapshot of your changes. When you want to add a new feature or fix a bug—no matter how big or how small—you spawn a new branch to encapsulate your changes.

Should I always create a new branch?

Creating a new branch allows you to isolate your changes from the master branch. If your experimentation goes well you always have the option to merge your changes into the master branch. If things don't go so well you can always discard the branch or keep it within your local repository.

Can I switch branches without committing?

Originally Answered: If you do not commit and you switch branches (or pull), do you lose your tracked but uncommitted modified files (whether staged or not)? No. By default git checkout and git pull will refuse to perform an update that touches any files with uncommitted modifications (tracked or not).


1 Answers

Working out of a branch maybe a good idea if - for example - you are adding a phat new feature which wont be ready for a few weeks. Whilst you are working on your new feature, the Live app cocks up. What do you do if you havent branched (or tagged) from trunk (in this case the code branch supporting live) ? you have to revert all your work and maintain copies of your changes, ready to slap them back in when you have resolved your live issue, bad times...

like image 61
brumScouse Avatar answered Sep 28 '22 16:09

brumScouse