Git: deleting local "master" branch

Git: deleting local "master" branch

by Frank Ralf -
Number of replies: 2
Just want to move this discussion from the Git for Administrators talk page more into the open:

* INSTRUCTIONS SAY "The command (4) deletes the master that was created automatically by git-clone in (2) as we do not want it in this production checkout."
I do not understand why that "master" branch needs to be deleted. What happens if it is not deleted? --Joseph Rézeau 09:07, 30 March 2011 (UTC)

* AFAIU you might accidentally fetch code from a remote master branch which might not be the version you actually use locally. See User:Frank_Ralf/Git#Deleting_master_branch. --Frank Ralf 19:25, 22 July 2011 (WST)

If you clone for example MOODLE_19_STABLE to you local computer that will automatically create a local master branch which is also Moodle 1.9. However, the *remote* master branch in most cases will be another version of Moodle. So if you accidentally use fetch while on your local master branch that could wreck havoc.

Is that the correct reason?
Frank
Average of ratings: -
In reply to Frank Ralf

Re: Git: deleting local "master" branch

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'd say fetch is not a problem at all. Git tracks which remote branches are used to push / pull / merge with each local branch (unless you force it to use a different branch specifically).

I'd say removing local master branch avoids mistakenly checking it out and using the wrong version of the code. When you clone a remote git repository, local master points to remote master by default, which depending on the project usually means latest stable version or latest development version.

So if you need to use a specific version in your local repository (say MOODLE_20_STABLE) having only that local branch avoids any possible mistake; you can only checkout one local branch: the right one wink (of course, you can also check out any remote branch or even any particular commit in the repository history, but when you do that you are fully aware of what you are doing, or so I hope smile)

Saludos.
Iñaki.
Average of ratings: Useful (1)