July 25, 2019 03:37 pm GMT
Original Link: https://dev.to/slashgear_/git-tip-why-you-should-not-keep-a-local-master-branch-3400
Git TIP - Why you should not keep a local master branch ?
When working with git
, I have often made the mistake of maintaining a master
branch locally updated using these commands.
git checkout mastergit pull origin master
I've done this so many times. This allowed me to start a development by being up to date with recent changes.
In fact, it is not necessary to maintain local copies of the branches on which we are not working directly. We already have access to an intact local version of the remote branches.
All this time I could have just done:
git checkout origin/master
And when you want to work on new stuff, just use
git checkout -b my-feature origin/master
Keep in mind that this is valid for master as well as all other branches on which you do not work directly/on which you will commit.
You could also follow my colleague advises.
Florent Lepretre@superflaw@Slashgear_ In the same context you can add "never rebase on your local master if you have one" Personally I have a git rem alias that does "git rebase origin/master", so easy to write17:21 PM - 24 Jul 2019
Florent Lepretre@superflaw@Slashgear_ In general you should keep a minimum of local branches, when you've pushed them you have their remote image in your local repository. They won't disappear unless you prune them. Just get used to read what 'git fetch' prints, everything is there !17:27 PM - 24 Jul 2019
Let me know if you have any other tricks with Git!
Original Link: https://dev.to/slashgear_/git-tip-why-you-should-not-keep-a-local-master-branch-3400
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To