All these comments and no one is going to point out that this is invalid?
The git stage and git commit don’t have any terminator, so it’s all one “command” and will fail. Then there’s a single & between git commit and git push, so it would run in parallel, so it would also fail.
Also, don’t
git stage .
people. Or at least do agit status
before to make sure you didn’t stagefile-with-all-the-production-secrets
Pffft… all of my api keys are open source. Having more eyes on them will make them more secure!
The comma and ampersand are plain English, not one big command
Gut clone
cat ~/.bash_history | grep "gut add" | wc -l
I’ve typed that more times than I thought…
alias gut=git
echo alias gut=git >> ~/.bashrc
git gud
git: 'gud' is not a git command. See 'git --help'.
rekt
zsh: command not found: rekt
git help
They should add that command, just to screw up this joke
git rekt
Every once in a while, you can refresh your memory by reading the man page.
Or if, like me, you use Emacs, Magit exposes everything quite clearly.
How about
git commit-tree [Hash] -p branch1 -p branch2 … -m "Dummy Message"
Seeing Peter Griffin labelled as “HR”, I automatically pronounce the R as “Ah” in my head.
If you happen to forget the -m though, you may also need to have mastered exiting vim
What developer uses Linux in professional work? Maybe for on the side stuff but I haven’t seen any corporate Linux machines.
The entire IT ecosystem is built around Linux, because it’s so prevalent in servers, containers, budget hardware and the open-source community.
Yes, many companies don’t understand that and expect their devs to be productive on Windows. But in my experience, that’s an uphill battle.
In my company, we get very little IT support, if we decide to order a Linux laptop and we still have significantly less trouble with getting things set up to start coding.
Not to mention the productivity boost from having all the relevant technologies natively available + being able to script whatever you want.Macs are basically BSD, and Windows has WSL.
But Mac or WSL are not Linux.
deleted by creator
Everyone at Mentor Graphics did before it got gobbled up by Siemens in 2017. I don’t know if they still do.
Everywhere I’ve worked, you have a Windows/Mac for emails, and then either use WSL, develop on console in Mac since it’s Linux, or most commonly have a dedicated Linux box or workstation.
I’m starting to see people using VSCode more these days though.
I thought Mac was unix which is similar but different from Linux?
I think someone else said what it actually is in another comment. It’s functionally identical 90℅ of the time for me anyway,and I use CLI and vim on it.
They’re both UNIX-like, i.e. they both implement the POSIX specification and are therefore in many ways compatible.
But yeah, modern macOS is more directly derived from the original UNIX operating system.
Linux was instead implemented from scratch to be compatible with UNIX.
Me as an Emacs user, who omits -m on purpose to practice quitting vi in case I really need it
Shift-Z Shift-Z to quit vi. Let’s keep it simple, people!
you’re an emacs user who has vi set up as the default editor on your system?
(You can change it altering the $EDITOR env var)
I only use $EDITOR to launch vi from git. Emacs runs as a single process and is always open.
The day I configured
git
to use Geany for commit messages with a separate config specifically tuned for this, it improved my life by 300%~$ cat ~/bin/gitedit #!/bin/sh exec /usr/bin/geany -i -s -t -c ~/.config/gitgeany $@
Then in git config:
git config --global core.editor "gitedit"
Interviewer: It’s
git push origin main
now. Get out of here!Just set your default behavior.
I have only ever used simply “git push”. I feel like this is a “how to say that you barely know how to use git without saying that you barely know how to use git” moment:-D.
Normal distribution curve meme makes sense here - experts and noobs can both
git push
safely (but for different reasons)I can follow along re-typing the same commands told to me by a more senior dev just like any average monkey!
This reminds me of something I made a long time ago:
Since I am calling myself dumb, I estimate my progress to be somewhere perhaps at the 20th percentile marker? :-D One of these days I’ll RTFM and rocket all the way up to be dumb enough to properly qualify for “below average”! :-P
Hold Up
The first time you manually push like that, you can add the
-u
flag (git push -u origin master
) to push and set the branch’s default upstream. Afterwards, a plaingit push
while that branch is checked out will push the branch to that default upstream. This is per-branch, so you can have amain
branch that pulls from one repository and apatch
branch that pulls and pushes to a different repository.My strategy is to just type
git push
and get some kind of error message about upstream not being set or something. That’s a signal for me to take a second to think about what I’m actually doing and type the correct command.That’s a signal for me to
… google the error and randomly try stack overflow answers without really understanding them.
( I have changed)
You can default git to using your current branch and a specific upstream so you don’t have to put anything after git push
Thanks didn’t know that
Has git never told you that you should use
git push -u origin <branch>
when you push a new branch for the first time?
deleted by creator
What kind of wild west operation allows pushing directly to main?
That’s kinda the whole point of trunk-based development.
Lol no it is not
Single person operation pushes directly to main.
Hey there were like 3 of us lol! No joke that’s what I have done at a few of the smaller shops as an SRE/System Engineer
Employees who push first win and get to leave early. The rest would be the suckers who would merge whatever mess left behind by the early employees.
I never worked anywhere where they had this set up. I would push to branches and make pull requests, but always work in the production environment.
I was mainly working as a data engineer though so that’s probably why. It’s hard to have test environments since you can’t replicate all the enormous amounts of data between environments without huge costs.
There are many strategies for maintaining test environments for that kind of thing. Read-only replicas, sampling datasets for smaller replicas, etc. Plenty of organizations do it, so it’s not really an excuse, imo.
No I know. But it was “good enough” for the company and we never had any serious issues working that way either. If someone pushed a faulty commit, we just reverted it and reloaded the data from the source system.
A lot of companies have kind of bad solutions for this sort of stuff, but it’s not talked about and nobody is proud of it. But it keeps the environments simple to work with.
No kidding. Never push to main, and you most likely can’t. While I get the joke of the meme, I’d send the person packing if they don’t understand branching, and branch flow, rebasing or reverting. Even if you look up the command or do it all through your IDE, understanding the workflow of using git is important
Do you not use a fork as your origin, separate from the production upstream repo? I’ll push to my fork’s main branch for small or urgent changes that will definitely be merged before anything else I’m working on.
deleted by creator
If it’s a private repo I don’t worry too much about forking. Ideally branches should be getting cleaned up as they get merged anyway. I don’t see a great advantage in every developer having a fork rather than just having feature/bug branches that PR for merging to main, and honestly it makes it a bit painful to cherry-pick patches from other dev branches.
👆 This guy gits it
You kids with your fancy branch support back in my day we had CVS and RCS liked it
You mean “I just sent you zip file with my new changes via email, get fucked looser”?
Our changes land in main at my workplace, once they’ve received a code review and all CI checks pass (which includes tests, E2E tests, etc). We use feature flags rather than feature branches, so all diffs / pull requests are against main. We use continuous deployment which means changes are automatically deployed once landed. Changes roll out just to employees, then to servers used by a small percentage of users (2% I think), then everywhere. All risky changes are gated by feature flags so they can be enabled or disabled without a code push.
We did a similar way with tag based releases, first a test tag, the production tag when signed off.
They laid off everyone else so there’s no one to the code reviews now. So fuck it, we’ll do it live!
We just had a customer escalation caused by exactly this. One group relied too heavily on tribal knowledge for code reviews and didn’t want any other process. Once the tribal elders were gone, no one knew all the things to look for, and there was no other way to catch issues
As a Continuous Integration and Test guy, I was standing in the corner yelling “I thought you were DevOps. Where’s the automation?” Fine, Puppet/YAML doesn’t work with a traditional build and test, but you could have done syntax validation and schema validation that would have caught before the code review could have happened (and I showed them how a year ago, even offered to do it for them) and set up some monitoring to discover when you break stuff, before customers discover it.
Fuck those that use main. If you’re working on a library fork that has main and a project that has master you’re bound to invert the two.
“What do you mean I can’t checkout main? Oh right, here it’s master…”
For once that we had a standard, it had to be ruined.
Fuck those that use master. If you’re working on a library fork that has main and a project that has master you’re bound to invert the two.
“What do you mean I can’t checkout main? Oh right, here it’s master…”
For once that we had a standard, it had to be ruined.
The standard is now main.
The standard is now main.
Git itself does not use that standard yet, so at least now there are two competing standards.
I get that there are cultural reasons why the word master was loaded language, but still, it’s not like institutional racism will go away. Meanwhile, the rest of the world which doesn’t struggle with the remnants of slavery has to put up with US weirdness.
Git itself does not use that standard yet, so at least now there are two competing standards.
Just ran
git init
in a brand new empty directory, and while it did create amaster
branch by default, it also printed out a very descriptive message explaining how you can change that branch name, how you can configure git to use something else by default, and other standards that are commonly used.Also, there’s nothing saying your local branch name has to match the upstream. That’s the beauty of git - you have the freedom to set it up pretty much however you want locally.
Yeah, that’s what I’m saying, there is no one standard now. The stupid thing is all the problems that causes is mostly because there used to be one, and stuff written assuming
master
branches are eternal.I’ve had a company that had some automation built on git but below GitLab that would not let you delete
master
branches. Whenmain
became a thing, they just started hard protecting those as well by name. It’s because of regulatory, and they are very stingy about it.So when I created a few dozen empty deployment repos with
main
as the default, and then had to change it over tomaster
so that it lined up nicer with the rest of the stuff, I’ve had a few dozen orphaned undeletable emptymain
branches laying around. A bit frustrating.That said, the whole thing is just that. A bit frustrating. If it makes some people feel better about themselves, so be it. I am blessed in life enough to take “a bit frustrating”.
Yeah that’s fair, I can see how that would be annoying for sure. I think that frustration stems more from company policy though, not necessarily the standard changing. And you know what they say, there’s nothing certain in this world except for death, taxes, and standards changing
It is trash code for sure, but most of the world’s code is trash, so we do have to accommodate trash code when we design stuff. That said, they do need to do this to comply with laws and make sure code doesn’t get lost (it’s finance), and this was the easy way to do it. Doing it better would have taken time and attention away from other stuff.
And standards do change, but they usually change to accommodate new features, or a new software product displaces an old one. I don’t really know any tech standard that changed because of cultural reasons. Point is, change is a cost. It may be worth to pay the cost, but here the benefits were US cultural sentiments that most of the world doesn’t care about.
And the stupid thing is that even when standards change, you are not usually labelled as culturally out of touch if you don’t follow it. Most big orgs don’t follow changes that they don’t need to. Nobody calls you a bigot for running COBOL mainframes in 2023, but they might if you predominantly have
master
branches.I guess my perspective is that some people I know were mildly annoyed before lunch about it one day two years ago, since nobody cares about US identity politics, with my personal opinion being if the US didn’t fill up its for-profit prisons with black people who it then those prisons profit off of (just as an example), the word
master
would not bite as hard, and the whole thing would be moot.
I think the reasons was ridiculous. The fact that people didn’t like the word master anymore. But I’m used to it now, so fine, let’s use main. It makes sensitive people feel better.
git checkout ma<tab>
If you don’t have autocomplete set up for your shell, get it working. If someone has a different branch named
ma...
, ask if you can delete it, and get your team to adopt a decent branch naming convention.git checkout ma<tab>
mai_new_chenges march_deploy_second_final_final_fixed main_fixes mast_not_farget_to_delete_it
…yeah, I already said that if there is another branch starting with those letters it should be deleted. You need a naming convention.
I really wish to work in a team where people have naming conventions for branches that are concerned about stuff like that. Must’ve been a nice place to work at.
Whoever named the “final final fixed” one seems to have missed the point of version control. 😑
My git knowledge:
git clone <url>
I once had HR ask if I was familiar with G-I-T ( she spelled it out), for a moment, my only thought was “wtf is G-I-T”.
One of my first interviews in Canada I was asked what a “zed-index” is and was like what? A what now?
Whenever I hear someone say “zed”, it always throws me for a loop. I follow a Canadian streamer, and they use it in place of
“zero”the letter “zee”.I’m not Canadian, but as a Brit I also say Zed instead of Zee but I’ve never heard someone say Zed instead of Zero. WTF.
Oh, my bad. It was zed instead of the letter “zee”.
It’s 3am, and I’m exhausted, about to head to bed.
I might be the dumb one in this one, but HR asked me if I know “design patterns”.
“I mean, yes, I know some design patterns. Any specific?”
“No, just if you are familiar with design patterns.”
“I mean, there are builder, strategy, sigleton, factory etc. Is the question really not more specific?”
“My paper just asks if the dev is familiar with design patterns.”
“Ok. Yes.”
Ahh, that must be where the DEVs use LUA and JAVA and whatever else always irks me. grumps irkily, for emphasis and illustration
As someone who knows that they know very little about git, this thread makes me think I’m not alone.
I think advanced git knowledge, like RegEx, is the exception, while the norm is to know the tiny handful of day to day useful bits
How is regex git knowledge? I guess you can use regular expressions with
git grep
but it’s certainly not a git-oriented concept…what. that’s not what they said. they are comparing git knowledge to regex knowledge.
Ah, thanks for the explanation. I too misunderstood the inflection.
no worries
I don’t even know how to respond to this considering it has nothing to do with what I said…
There are at least two ways to parse your statement, and they interpreted it differently from your intention.
I guess, if you ignore the comma…
Rereading it, I now understand what you meant. I interpreted the “like regex” as an example of advanced git knowledge. I’m not sure the comma helps make it unambiguous though.
Yeah, reading it again and I can see that interpretation…
This is why you shouldn’t rely on yourself alone for proofreading your writing, I probably could have read that a hundred times and not seen another way to read it without someone else pointing it out
Could’ve written like this to avoid the ambiguity: “I think advanced git knowledge, just like RegEx, …”
So do you guys pronounce it git or jit
The same as in giraffes giving ginormous gifts
So, it’s pronounced “jight”?
Don’t start this. Its not like gif. Git is clearly pronounced like git. There is no possible argument you can make otherwise.
Same could be said about gif yet here are
jean, we pronounce it jean.
Yit
fortunately this one isn’t an acronym. so the pronunciation is obvious. 😊
Acronyms are still pronounced like the words they most closely resemble though
This guy jits it
But git is not an acronym
Is that what we’re going to do tonight, we’re gonna fight?
lol it’s on now!
I pronounce it the correct way you silly git!
Git off my lawn. Git!
The holy war we deserve.
no
Once you understand that everything is similar to a tag, like branch names are basically tags that move forward with each commit, that HEAD is a tag that points to your current commit location in history, and what command moves what kind of tag, it becomes easier to understand.
Suddenly having a detached HEAD isn’t as scary as you might think. You get a better understanding of fast forward merges vs regular 3-way merge.
Also understanding that each commit is unique and will always remain in the history and can be recovered using special commands. Nothing is lost in git, unless you delete the .git sub-directory.
Orphaned commits can get garbage collected at some point, though.
Oh fuck. I didn’t think of that. Than you for reminding me.
Edit: Ah but you can only run this in your local repo. If you happen to push anything, you might not be able to run it on the remote. Many DevOps platforms won’t allow it.
Oh yeah, and anybody else who had fetched in those commits may still have them as well. It’s hard for something to be gone-gone, but it may be annoyingly-hard-to-recover-gone.
For folks unaware, the technical git term, here, is a ‘ref’. Everything that points to a commit is a ref, whether it’s HEAD, the tip of a branch, or a tag. If the git manpage mentions a ‘ref’ that’s what it’s talking about.
Right. I just wanted to keep it as simple as possible.
Oh, no worries, just figured I’d add that extra little bit of detail as it’s a useful hook into a lot of other git concepts.
Honestly I’ve come to realise that being precise is the simplest in the long run
People get overloaded with words. You have to focus on one concept at a time. Let them ask for others.
This I call decapitation
git commit -am
You don’t just git to edit past commit