Re: why is git destructive by default? (i suggest it not be!)
- From
Brandon Casey <casey@nrlssc.navy.mil>
- Date
- Jun 24, 2008, 18:18 UTC
- Message-ID
- <B7VXwxfjnTa8aYUBhy6fPK8N4wDq9i91R-fo4xot3lQCjt87hBafoQ@cipher.nrlssc.navy.mil>
- In-Reply-To
- <48612ABE.6000104@panasas.com>
Boaz Harrosh wrote:
> I use git reset --hard in to separate and distinct functions. > One - to move current branch head around from place to place.
Why?
> Two - Throw away work I've edited
This is valid.
> It has happened to me more then once that I wanted the first > and also got the second as an un-warned bonus, to the dismay > of my bosses.
Why are you using 'git reset' to do this? Why not just checkout the branch? I think you are using 'reset' in ways it is not intended to be used. Is there something in the documentation that led you to believe that 'reset --hard' should be used to switch branches? I do see an example of such a thing in everyday.txt. It deals with setting 'pu' branch to the tip of the 'next' branch, but the 'pu' branch has a special meaning in git.
It seems like you are using 'reset' when you should be using 'checkout'.
For example:
$ git branch * mybranch master next maint pu
If I have 'mybranch' checked out and I want to make a change on top of the 'next' branch, I wouldn't do 'git reset --hard next', I would either 'git checkout next' or 'git checkout -b next-feature next' or something similar.
If I've already merged the changes from mybranch back into upstream, then it's safe to delete it.
I recommend adopting a branch naming scheme where the branch name describes the task that is to be accomplished. i.e. 'foo' is a bad branch name.
btw, you are not saving anything by trying to reuse branch names. All a branch is, is a file with a 40 byte string and a newline. So creating a branch entails writing 41 bytes to a file. Deleting a branch entails deleting a single file that is only 41 bytes small.
I suggest trying to adjust your work flow so that 'reset --hard' is not necessary.
-brandon