Git help - branches with no commits?
-
What do you use for your main production branch, ala trunk in svn?
A branch named "development", more or less. Like I said, occasionally there are hot-fixes to a specific version branch (all named "release/vX.Y").
The weird results of this command might be because I wasn't on the development branch when I ran it, because I didn't know that mattered. I was on one of the bug fix branches.
-
Oh, this is literally the first time you've mentioned that it's important what branch I'm currently on. Haha.
Git basics: unless told otherwise, all commands refer to current branch. "master" in the lines @asdf gave you was specifying a branch. When it's omitted, Git defaults to current branch. If you don't mean the branch "master", replace it with the name of the branch you want.
-
I was on one of the bug fix branches.
Yup, so it gave you every branch not part of this branch. You want to toss a "development" after --merged then.
-
but if you literally don't have a master branch,
The thing is I didn't know if I had "a master branch". I could have told you I didn't have a branch named "master", if you had simply asked. Since I don't know what the term "master branch" implies, I had no idea that was even a question I should have wondered about.
(I also wonder why you'd simply assume we have a branch named "master", but whatever. I guess that's the GitHub default?)
Yup, so it gave you every branch not part of this branch. You want to toss a "development" after --merged then.
Right; but that still doesn't work because it'll give me branches that have hotfixes in them that didn't go into "development". I still have to go through them one-by-one manually. Ugh.
Well, at least there's only 19 I have to go through manually, that's a heck of a lot better than before.
The bad news is that means about 100 of the branches in Stash have some form of commit in them but have never been merged, there's no automated way to deal with that shit except by maybe going by date and deleting old ones? I dunno.
-
Hmm... maybe some way to output and sort by last-commit date? I don't know git well enough at that point, but that sounds like it should be possible. Something like:
but replace
git branch -r
with the command you have now.
-
... yeah that ain't gonna happen. It'd take me longer to figure out what the fuck that gibberish is doing than it would for me to just manually clean out the repo.
-
The thing is I didn't know if I had "a master branch". I could have told you I didn't have a branch named "master", if you had simply asked. Since I don't know what the term "master branch" implies, I had no idea that was even a question I should have wondered about.
Yeah, sorry, my instructions were a bit unclear. It's 1am where I currently am.
One thing you can remember is that "master" and "origin" are not special at all. It's just a convention to call your main branch "master" and your main remote repository "origin". If they are called differently at your workplace, just mentally replace "master" with "development" all the time.
(I also wonder why you'd simply assume we have a branch named "master", but whatever. I guess that's the GitHub default?)
If you create a git repository, git creates exactly one branch named "master". Everyone uses that as their main branch, it's a convention. Not limited to Github, every application that uses git does that by default.
Similarly, if you clone a git repository, git creates exactly one remote named "origin". Nothing special about that name, either, it's just the convention that almost everyone uses.
-
The bad news is that means about 100 of the branches in Stash have some form of commit in them but have never been merged, there's no automated way to deal with that shit except by maybe going by date and deleting old ones? I dunno.
Would the hotfix type branches that were never merged back into development be tagged if they were released?
-
If they are called differently at your workplace, just mentally replace "master" with "development" all the time.
That's fine, but remember for next time the people you're talking to aren't telepathic. Don't use a term like "the master branch" (which sounds like a special thing) instead of just "a branch named 'master'." (which is just the name of one branch out of hundreds).
If they are called differently at your workplace, just mentally replace "master" with "development" all the time.
The whole concept is dumb because every release we do has its own "master". So...? Like what Git's doing here doesn't even make sense to me. There's no one "master", release 4.5 has a "master" and release 4.6 has a "master" and release 5.2 has a "master", etc. I mean isn't that the point of using a tool like Git?
If you create a git repository, git creates exactly one branch named "master".
That is demonstrably not true. :)
Everyone uses that as their main branch, it's a convention.
Also demonstrably not true.
Would the hotfix type branches that were never merged back into development be tagged if they were released?
I have no clue. I doubt it?
Of my list of 19 it looks like only 4-5 of them are hotfixes intended for a non-Development branch, and of those it looks like most of them are dead and forgotten.
-
The whole concept is dumb because every release we do has its own "master". So...? Like what Git's doing here doesn't even make sense to me. There's no one "master", release 4.5 has a "master" and release 4.6 has a "master" and release 5.2 has a "master", etc. I mean isn't that the point of using a tool like Git?
Basically, the way most people use Git, "master" is the same as "development" in your case: The branch which all the release branches originate from.
-
The branch which all the release branches originate from.
Well right, but once they've been "originated", they're now masters of their own little domains and they can get hotfixes and the like.
Whatever, everything to do with Git gives me a headache, and it's after 4 PM so I'm heading home.
Thanks for the help. At least I have a narrowed-down list I can shove in a JIRA ticket.
-
Well right, but once they've been "originated", they're now masters of their own little domains and they can get hotfixes and the like.
Exactly.
-
Exactly.
... right, but then you're not getting my point that I can't just look for branches that are merged into development, I need to find branches that are merged into development or any of the release/vX.Y branches. Which apparently is impossible?
-
... right, but then you're not getting my point that I can't just look for branches that are merged into development, I need to find branches that are merged into development or any of the release/vX.Y branches. Which apparently is impossible?
Ah, okay.
Where I work, we usually merge the hotfixes from relase-x.y branches back into "master". If you don't do that, then you'd have to execute "git branch -a --merged <branch>" for every release branch as well as "development". If you can think a way to easily generate a list of those branches (e.g. listing all branches and matching against a regex?), that could be automated as well.
-
I need to find branches that are merged into development or any of the release/vX.Y branches. Which apparently is impossible?
If the branch label has been deleted, it is indeed impossible; the info doesn't exist at that point. Otherwise, it's just that the default tools don't do that; they insist on processing a single branch at a time. You have to ask for each branch that you've got as an “interesting” merge target, which is scriptable, but it's a good excuse to use a GUI tool. Development without a tool to provide some sort of heads-up as to WTF is going on on other branches is much harder, and this is where GUIs shine…
-
If you can think a way to easily generate a list of those branches
There's a way. It's fucking awfully misanthropic. (It's git, so that's to be expected…)
-
There's a way. It's fucking awfully misanthropic. (It's git, so that's to be expected…)
Urgh. I'd rather pipe the output of
git branch
into grep, thankyouverymuch. Also,git for-each-ref
doesn't have many useful options in Git 1.9.If the branch label has been deleted, it is indeed impossible; the info doesn't exist at that point.
In this case, the branch won't show up in the Stash UI anyway and
git gc
will collect the commits at some point, so we don't have to worry about that.You're just confusing blakey here, what he wants seems to be doable.
-
In this case, the branch won't show up in the Stash UI anyway and git gc will collect the commits at some point, so we don't have to worry about that.
No, because convergences in the history of extant branches will still show up (assuming that a merge-based workflow is being used). You just won't see what name they were labelled with.
-
I still don't think we have to worry about that.
-
... right, but then you're not getting my point that I can't just look for branches that are merged into development, I need to find branches that are merged into development or any of the release/vX.Y branches. Which apparently is impossible?
Wait, so you're saying that the development branch doesn't have the release/vX.Y branches in its history? How does that work? Let's say you create a new branch off of development called release/v3.2. It doesn't have the release/v2.7 branch in it's history?
-
Why would a release branch be contained within the development branch?
That just sounds like trying to cause a horrific merge nightmare when doing hotfixes to old versions of the software.
-
I think the point is you merge the hotfixes from the release branches back into development
-
Let's say you create a new branch off of development called release/v3.2. It doesn't have the release/v2.7 branch in it's history?
It has 99% of it, but there's a chance v2.7 has a hotfix that isn't in v3.2. (Because we instead spend more time and fixed it in a better, more maintainable, way.
I think the point is you merge the hotfixes from the release branches back into development
We don't (always) merge our "this has to be working YESTERDAY!" emergency hotfixes into "development". "Development" is for tested, quality code.
-
Ah, yeah, that makes sense. I wasn't thinking about doing hotfixes for old releases. I guess I was just in a web app mindset where there's only one current version.
So I guess he's looking for all branches that aren't in the history of any other branch.
-
My GitHub-provided Git says this:
git version 2.5.3.windows.1
-
We don't (always) merge our "this has to be working YESTERDAY!" emergency hotfixes into "development". "Development" is for tested, quality code.
:sigh::longing_stare:
If the development branch compiles it's a victory at WtfCorp.
-
I guess I was just in a web app mindset where there's only one current version.
That's adorable. Have a lollipop.
Most webapp development doesn't really have to consider more than one actual deployment. Building webapps for other organisations to deploy is a horse of an entirely different colour…
-
I need to find branches that are merged into development or any of the release/vX.Y branches. Which apparently is impossible?
Sounds like you need to run this command from / while on each of the branches and take the intersection of all the results.
-
adorable. Have a lollipop.
Most webapp development doesn't really have to consider more than one actual deployment. Building webapps for other organisations to deploy is a horse of an entirely different colour
Thanks! Mmmmm... Tastes like merge conflict.
-
Ah, yeah, that makes sense. I wasn't thinking about doing hotfixes for old releases. I guess I was just in a web app mindset where there's only one current version.
We write a web app. Not all our clients are on the same version of the software, though. We're trying to wrangle them.
I think you're in a "shitty open source developer who doesn't give a shit about software quality" mindset.
-
My GitHub-provided Git says this:
git version 2.5.3.windows.1
Congratulations. Where do I send the roses?
-
Ok well I guess the "quote reply" button just doesn't work anymore, so whatever.
Yeah, I think you're right, the problem is that rapidly approaches "more effort than it's worth." I'm annoyed that I constantly get people telling me how Git is like this mega-genius power tool, and I'm trying to do a pretty simple thing here (IMO) and it turns out to be nearly impossible. WTF?
Oh well, it's in triage, if it gets assigned to me I might have follow-up questions.
-
I think you're in a "shitty open source developer who doesn't give a shit about software quality" mindset.
Congratulations. Where do I send the roses?
Something something help category...
I'm annoyed that I constantly get people telling me how Git is like this mega-genius power tool
Me too. But I'm also annoyed by people who don't bother to understand Git (or even actively, purposefully misunderstand it, or at least pretend to) and then go around yelling to everyone how much it sucks.I'm trying to do a pretty simple thing here (IMO)
Yes, IMO. In your opinion that completely disregards how Git actually works and replaces it with some wishful thinking about how you think it should behave.and it turns out to be nearly impossible
It is very possible; it's just that:- Your OP wasn't clear at all about what you want to do.
- It took you way too long to tell that you have multiple "main" branches.
- You didn't even try to understand the commands you were blindly copy-pasting from here, as evident by how you asked what the "master" mean long after you posted error messages complaining about "master" not being valid branch.
- You are lacking the basic Git skills, as evident by you not knowing that the branch currently checked out affects Git commands you were blindly copying.
- You don't have xargs.
But the ultimate reason why the whole discussion wasn't very helpful is because the thing you wanted to do is very easy and not that time-consuming to do manually via your GUI thingy. I would link relevant xkcd about automating stuff, but I know you hate them, so I'll pass.
-
I think you're in a "shitty open source developer who doesn't give a shit about software quality" mindset.
It was late, and I've spent the last few years working on an in-house web app where there's only one current version. Fuck off. Sorry for trying to understand your poorly worded question and give you a hand.
Maybe next time, you should read any absolute beginner tutorial on git before asking questions and looking like an idiot yourself. "Waaaa, I didn't understand what you meant because I don't have a 'master' branch". That sounds like giving someone a code snippet for string splitting and seeing them reply, "But I don't have a variable called 'myString'!"
-
I'm trying to do a pretty simple thing here (IMO) and it turns out to be nearly impossible
It's certainly possible, the biggest problem so far was a misunderstanding between the two of us and that I used the wrong argument order.
-
Something something help category...
The question's closed; the help is given.
You were being a condescending asshole when the question was still open. You were just treating it as another excuse to hurl insults at me. Guess what? Fuck you.
Your OP wasn't clear at all about what you want to do.
Hey, here's a thought: if you're unclear on something, ASK QUESTIONS!
It took you way too long to tell that you have multiple "main" branches.
If you're unclear on something, ASK QUESTIONS!
You didn't even try to understand the commands you were blindly copy-pasting from here, as evident by how you asked what the "master" mean long after you posted error messages complaining about "master" not being valid branch.
If the error message had said "master is not a valid branch", I would have figured it out in no time at all. What I got instead was:
fatal: malformed object name master
I don't even slightly know what that means, nor do I know what to do about it, nor would ANYBODY who hasn't asked for an explanation because this error message is not only badly-written, but it's a blatant lie. "master" isn't a "malformed object name", it's the name of an object (formed perfectly fine) which doesn't exist.
So, yes, you're right: I'm a stupid idiot for not understanding that that error message means something ENTIRELY DIFFERENT than it says.
You are lacking the basic Git skills, as evident by you not knowing that the branch currently checked out affects Git commands you were blindly copying.
Thus my asking questions about it.
You don't have xargs.
What is that, some kind of alien dog-monster?
No I don't have "xargs".
Sorry?
But the ultimate reason why the whole discussion wasn't very helpful is because the thing you wanted to do is very easy
Is it? It took quite a bit of back-and-forth here before I got anything workable. If this is "very easy" by Git standards, what does that say about Git?
and not that time-consuming to do manually via your GUI thingy.
Stash has no filters to display the branches I was looking for. Given: if I had known in advance that only 20ish of the 130ish junk branches were devoid of commits, I wouldn't have focused on finding them first.
I would link relevant xkcd about automating stuff, but I know you hate them, so I'll pass.
When did anybody in this thread talk about automating ANYTHING? WTF are you talking about?
Maybe the problem here isn't my lack of explanations, but that you have magic beams from Jupiter inserting thoughts into your mind.
-
Maybe next time, you should read any absolute beginner tutorial on git before asking questions and looking like an idiot yourself.
I don't care if I look like an idiot, I'm just trying to get work done. I don't want to spend 400 hours tinkering with shitty development tools, I want to do my job.
"Waaaa, I didn't understand what you meant because I don't have a 'master' branch".
I like how you and Gaska are just ignoring that the error message is A BLATANT LIE.
That sounds like giving someone a code snippet for string splitting and seeing them reply, "But I don't have a variable called 'myString'!"
The phrase "the master branch" implies something different than a branch that merely named "master". For all I knew, our "Development" branch was "the master branch".
-
It's certainly possible,
Yeah, using the method Boomzilla outlined. The problem is, it's more effort than just manually looking through the list, which puts it in the "what the fuck is the point anymore?" bucket.
-
If the error message had said "master is not a valid branch", I would have figured it out in no time at all. What I got instead was:
fatal: malformed object name master
After reading the man page, the error message starts to make sense. The argument can be something entirely different as well, like a tag or a commit.
-
After reading the man page, the error message starts to make sense.
It does?
So that means if I tried to make a branch named "master", it would be rejected by Git because that name is "malformed"?
Because you told me yesterday that Git, BY DEFAULT, makes a branch named "master". (Which isn't true, but whatever.)
So which is it? Either "master" is a "malformed object name" or it ain't. You can't have it both ways.
The argument can be something entirely different as well, like a tag or a commit.
That doesn't make the error message make sense. It might make it incomplete.
-
malformed
Ok, yeah, I agree. The word "malformed" doesn't make any sense. A better error message would be: "master does not refer to any object known to git".
-
Hey, you're the one who said it made sense.
This is why, contrary to Gaska's advice, I don't want to learn anything more about Git, nor do I see learning more about it as a desirable thing. Because people who know a lot about Git get the brain-worms and start defending all the OBVIOUSLY WRONG AND STUPID behaviors it engages in. And I'm never, NEVER, going to be the person defending an error message that's a blatant lie.
-
The phrase "the master branch" implies something different than a branch that merely named "master". For all I knew, our "Development" branch was "the master branch".
My point is, that's 101 stuff. It doesn't take 400 hours to learn that. It takes one.
-
My point is, that's 101 stuff. It doesn't take 400 hours to learn that. It takes one.
Demonstrably not. Since I've been working with for for a lot closer to 400 hours than 1, and I didn't know it until yesterday. (I'm not sure I've ever worked with a Git repo that had a branch named "master" in it, honestly. The one 3 jobs ago I don't remember with crystal clarity, it might have had "master".)
But hey I guess I'm just stupid retard dumb-o man. Obviously that's the only possible explanation, since Git is SO intuitive and easy-to-use.
-
Demonstrably not. Since I've been working with for for a lot closer to 400 hours than 1, and I didn't know it until yesterday. (I'm not sure I've ever worked with a Git repo that had a branch named "master" in it, honestly. The one 3 jobs ago I don't remember with crystal clarity, it might have had "master".)
But hey I guess I'm just stupid retard dumb-o man. Obviously that's the only possible explanation, since Git is SO intuitive and easy-to-use.
I realize you're arguing with several people, so maybe you're confused about what I said. I never said git was easy. It's hard. It's a very powerful tool, but ease of use isn't one of it's big features.
-
The question's closed; the help is given.
I don't see it marked as closed, I don't see any post selected as correct answer, however, I see you said that there might be further help needed later. You can't really blame me for not figuring out the question is closed and rules have changed, can you?Hey, here's a thought: if you're unclear on something, ASK QUESTIONS!
If you haven't noticed, MY VERY FIRST POST WAS A HUGE QUESTION TO YOU. Complete with ahead-of-time responses to all the possible answers you might give!If you're unclear on something, ASK QUESTIONS!
I don't ask questions that aren't relevant. And at the time, they weren't relevant yet. Because you skipped crucial info.> fatal: malformed object name master
I don't even slightly know what that means
Because you don't know Git basics. Specifically, you don't know what an object is. If you knew that objects are, among others, branches, and knew that "master" is the default name for a main branch and you don't have a branch named "master", I'm sure you would figure out you have to replace it with another name."master" isn't a "malformed object name", it's the name of an object (formed perfectly fine) which doesn't exist.
Under Git definition of name, a name that refers to something that doesn't exist is malformed. Since they make the rules for their own software, you cannot say their definition is wrong. Impractical - maybe, but still not wrong.So, yes, you're right: I'm a stupid idiot for not understanding that that error message means something ENTIRELY DIFFERENT than it says.
It means exactly what it says. The fact it uses different definitions of some words than you are used to doesn't change that.Thus my asking questions about it.
Asking questions is fine because you don't know basics is fine. Saying Git is shit because you don't know basics is not.What is that, some kind of alien dog-monster?
No, it's something that solves the "I don't want to repeat this command for every branch separately" problem.No I don't have "xargs".
And neither did you look up what it is and what it's for after I mentioned it.Is it?
Well, yes, clicking "delete" button in Stash interface is fairly simple, I presume.It took quite a bit of back-and-forth here before I got anything workable. If this is "very easy" by Git standards, what does that say about Git?
Most of the back-and-forth was spent on gaining new informations from you. Also, you have reading comprehension problems - I was saying it's very easy to do with Stash GUI, not Git commands. Inb4 - doing it with Git commands is still fairly simple, but only if you know exactly what you have and what you want to do.Stash has no filters to display the branches I was looking for. Given: if I had known in advance that only 20ish of the 130ish junk branches were devoid of commits, I wouldn't have focused on finding them first.
Ok, sorry then. For the whole topic, I thought that you do have this info available in Stash, somewhere (not necessarily in a convenient place). My bad. Thankfully, this info is mostly irrelevant to discussion.
-
I never said git was easy.
I never said you did.
I was just demonstrating that your statement was wrong, using myself as the evidence.
-
The phrase "the master branch" implies something different than a branch that merely named "master". For all I knew, our "Development" branch was "the master branch".
You're completely right. You just forgot that on 99.9999% of Git repos, the master branch is literally named "master".Also, "Development" is not the only master branch you have - which adds some complexity.
Because you told me yesterday that Git, BY DEFAULT, makes a branch named "master". (Which isn't true, but whatever.)
It is true, actually. Go ahead and try outgit init
command - you'll end up with "master" branch checked out (unless you specifically say not to do that).This is why, contrary to Gaska's advice, I don't want to learn anything more about Git, nor do I see learning more about it as a desirable thing.
And then you go back to this forum with every little thing you have trouble with - trouble you wouldn't have if you spent some time actually learning Git.Because people who know a lot about Git get the brain-worms and start defending all the OBVIOUSLY WRONG AND STUPID behaviors it engages in.
Are you afraid you'll become the same? You must have very weak mind. Notice that I never said any of Git error messages are good (they obviously aren't); all I said is that they make sense under Git's definitions of words. That's very different.And I'm never, NEVER, going to be the person defending an error message that's a blatant lie.
So are you going or aren't you? If you're not, then the negative effects of learning about Git won't affect you, right?Since I've been working with for for a lot closer to 400 hours than 1, and I didn't know it until yesterday.
Because you never even tried to learn. And don't tell me you tried because just one post earlier you explicitly stated you don't want to learn Git.
-
You don't have a
master
branch?The reason that confused people is there's nothing actually special about
master
it's just a branch namedmaster
(usually, sounds like it isn't in your case) where your first commits are and what everything gets merged back into because it makes sense as a name and a concept. Therefore the concept and implementation are usually conflated.
-
I don't see it marked as closed, I don't see any post selected as correct answer, however, I see you said that there might be further help needed later. You can't really blame me for not figuring out the question is closed and rules have changed, can you?
I don't really care what you think.
You've never, ever, replied to anything I've written on this forum except to call me an idiot. Not once. Ever. Frankly, I'd be happier if you just stayed the hell out of ALL of my threads. Probably you would, too.
Under Git definition of name, a name that refers to something that doesn't exist is malformed. Since they make the rules for their own software, you cannot say their definition is wrong. Impractical - maybe, but still not wrong.
Wow. You must be Gumby to be able to stretch that far to come up with some excuse why that's not an awful error message.
Asking questions is fine because you don't know basics is fine.
The thing you miss is I do know the basics. I use Git successfully every fucking day, despite its best attempts.
Saying Git is shit because you don't know basics is not.
I say it's shit because it's shit.
No, it's something that solves the "I don't want to repeat this command for every branch separately" problem.
If you're going into "want", I didn't want to do any of this bullshit at all. What I want is a big ol' button in Stash that says "clean up branches with no commits" than I could push in and be done with this shit instantly.
In any case, running it on every branch is great but that's only part of the problem. Then you have to get the results of every run and find their intersection, which I dunno, maybe "xargs" can do that, but I'm guessing it's much more likely that you, like all open source developers, only solved 1/3rd of the problem then arbitrarily declared it "done".
Well, yes, clicking "delete" button in Stash interface is fairly simple, I presume.
Deleting them is simple; FINDING them is difficult.
I was saying it's very easy to do with Stash GUI, not Git commands.
Then tell me how. Because I couldn't figure it out.
For the whole topic, I thought that you do have this info available in Stash, somewhere (not necessarily in a convenient place).
Oh; so that last post was based on an ass-pull assumption? Awesome. Great. Talking to you is so intellectually fulfilling.
You're completely right. You just forgot that on 99.9999% of Git repos, the master branch is literally named "master".
I can't forget something I never even knew in the first place.
It is true, actually. Go ahead and try out git init command - you'll end up with "master" branch checked out (unless you specifically say not to do that).
I've worked with tons of Git repos that do not have a branch named "master".
And then you go back to this forum with every little thing you have trouble with - trouble you wouldn't have if you spent some time actually learning Git.
And it never occurs to you that if I've been using Git for this long, and haven't "learned" all this stuff you consider is so critical, maybe that's Git's fault?
Notice that I never said any of Git error messages are good (they obviously aren't);
Haha, just in your previous post you grabbed logic by the neck and squeezed to somehow justify that dumb "malformed" error message, which is obviously wrong to any human being with a 3rd grade education. Now you've flip-flopped completely. Awesome.
Because you never even tried to learn.
If there's something I need to know to use Git, it's Git's responsibility to teach it to me. If it hasn't, that's because Git is terrible software.
You don't have a master branch?
No. Like I said, I'm not sure I've ever worked with a Git repo that had a branch named "master".
The reason that confused people is there's nothing actually special about master it's just a branch named master
Right; but when you say "the master branch", that doesn't imply a branch named "master". Not to me at least. It's a totally different implication. Like I said above, for all I knew, "development" was "the master branch" in our repo.
because it makes sense as a name
It does?
What makes that branch the "master" over all the other branches? Which, I suppose, are "servants"?