git pull git status git add . git commit -m āupdā git push
git stash push git pull git stash pop
Very useful for cases where conflicts with local changes happen.
This way, it is easier to deal with merge conflicts for me
I was wondering what git stash push
does since Iāve never used it. Apparently itās the same as just git stash
Yea it is useful when you want to stash one file, e.g. git stash push main.c
git gud -f scrub
āgit commit -am āmsgāā
Why many args when few possible
Itās like when my last company couldnāt believe I didnāt use a gui to manage my commits. Just leave me and my commands alone man, I like them, they work, I know my lane š
Tbh sometimes I find the GUI more difficult to use than command lines
I come from a sysadmin background and I just am more comfortable with CLI than GUI for 90% of tasks
Same. It's also just drastically faster most times anyway.
No it's not. I use a combination of CLI and GUI and for most basic stuff GUI is faster. Maybe your repo is super basic and your branch names are 1 or 2 characters long (or you don't use branches at all) so it's quick to type stuff. There's no way I'm typing out a 20+ character branch name in one pass without any typos, faster than it takes me to make a couple of clicks.
.... you know you can tab complete branch names right?
does that work on windows cmd?
use powershell instead of the command prompt and it does
Unsure, I use zsh on osx and linux, and wsl a zsh if i need to do work on windows.
I use zsh on osx
Same but mainly because pretty colors.
GitHub desktop is navigable by a toddler
Iāve used it for pull/commit/push/checkout (the basics).
How is it for the more advanced stuff?
VSCode and Github desktop make resolving merge conflicts pretty easy. I don't know how you would do this without the GUI offered by VScode at a minimum for comparing diffs.
Cherrypicking commits or going back in time is easy. Stash is easy. Not sure really what else you would need.
I do use VS Code for resolving merge conflicts, but everything else is done via CLI. I just learned that way, and it throws me whenever I see someone using a GUI for it. I tried using one once, and it lasted about half an hour.
Yeah- that's the problem. It's not usable for any mildly complex task.
Can you give me an example of a ācomplex taskā scenario you encounter regularly? I work on a large team and we follow fairly strict rules about how/when to create branches and merge them. In several years Iāve never seen anything that the command line would be better suited for other than flexing on interns
I don't use gui at all with git, not because it's not suitable for complex tasks, but because I find gui too complex for me. I understand the commands, I know exactly what I need to type, but with the gui I have no idea what I need to do and what effects my actions will have. Don't want to spend time learning that as well.
Isnt flexing the main goal here? Everything else is secondary
I'm trying to get a paycheck and spend as much time outside of that playing video games and rock climbing. Posturing is for peacocks.
I am the only cli user at my current workplace with 30 Devs.
Guess who always gets called when someone fucks their shit up via VS Code or a Jetbrains IDE.
Meanwhile if I remember in college everyone raised their eyebrows if you dared use emacs over vim. Thereās a definitely a superiority the less you used guis there
Emacs is not a GUI app.
I remembered everyone who used eMacs in college used a gui maybe itās has a gui and non gui version idk I barely used it because I was bullied into using vim
Yup, Emacs is an Operating System
Personally I couldnt care what someone uses as long as they use it correctly
As a dev lead I empower my other members to find a way that works for them, but if they need my help with it then we're going to do it my way.
Thats fair haha nobody wants to see the junior banging their head against a brick wall because theyre too stubborn to use a shovel and insist on digging with their bare hands
Git is very powerful but imo if you need to use those complex features regularly youāre doing something wrong. Command line is the best way to use git imo. Keep it simple. The GUIs are all way more complex than they need to be
Wow, I'm the only person I know who uses GUI for git. People always be giving me shit for it.
Anything you are familiar with and know how to use is good
If it's Gooey I'm pretty sure that means you didn't bake it long enough but I guess some people are into that
git good.
gitGud
Nah. Who else are we gonna git blame?
Git status in between every command cuz why not
Gotta do it otherwise the files will trick me
git reset --hard
git reset --hard origin/branch_name
For when you totally fucked up your local branch and want to redo
Yup. Or, as I call that situation, Tuesday.
Edit: nixed a trailing 's'.
rm -rf āno-preserve-root /
Then take a vacation.
git reset --hard so i trick my githook to not run conan update on git pull from main
There is so much fucking around with git history I could have avoided by just doing a hard reset and copying my changes back in. :/
I also use: git clean -df
When reset hard doesn't get rid of stuff like folders
git push --force | kms
What is kms
Kill myself
kms is not recognized as a cmdlet or function
sudo apt install kms
Ahh rookie mistake...first do sudo apt update
Kernel Mode Setting
But here itās probably key management service for pasting keys
I think in this case it's more about pasting oneself.
the software behind eve online's capsule system is much more straightforward than I could have imagined
You should always use --force-with-lease
as a precaution against overwriting recent commits from others. It should be the default in my opinion.
Masters dont use branches then?
Can't imagine life without branches and rebase
Git add; git commit -m; git push works perfectly well with branches, what are you on about?
You would likely need git switch
, git branch
or some of the extra parameters for commit and push for using branches
Unironically. Trunk Based Development is hot right now. Requires a CI pipeline with strong automated testing and judicious use of feature toggles.
Personally I prefer, Github flow (not gitflow), short lived feature branches and PRs to main with strong automated testing and some use of feature toggles.
gitflow/mulitple long lived branches is where most people's problems with git arise.
I was in a team where we had task branches with PRs to story branches, and when these stories where done and approved, they where merged to master. We did not care about rebasing/ keeping the history clean, though.
Where was this so I know not to apply there?
Thats about 5 years ago.. and as every team descided on how to work, it would have been different in other teams. Now I also work different, with smaller stories and PRs to main (and rebase instead of three-way-merge)
gitflow/mulitple long lived branches is where most people's problems with git arise.
100% agree
Same here, make branch, do some changes, update it from main and make PR. In 6 years and 3 companies, Github desktop was enough for me except for a few times that I needed some complex commands.
In one company we had main and dev branches, feature branches are made from dev, hotfix made from main. After feature is done, it is merged in the dev and main is merged in dev. After release is ready, main is updated from the dev and release is made.
What you call github flow we just refer to as a flavor of trunk based at my company, but I also prefer it. We do a branch for each jira card, so they usually don't live longer than a week.
Dev religions are hilarious.
How do you do that without rebase? Either this meme is dumb or Iām the guy in the middle.
Do what? TBD? Distilled to its essense, you commit directly to main, CI watches the main, runs automated tests, optionally deploys to a QA env, then when tagged with a version it deploys it to production.
How do you resolve merge conflicts if everyone is pushing to main? You must be doing rebase.
You can pull the remote main changes to local, merge with strategy other than rebase, then push to remote. If it is a small team within shouting distance, there likely aren't problems with multiple people trying to do that exact same time.
git merge is in the middle. I want to understand the workflow for the guy on the right.
What you described is not a feature branch, but just a branch.
Feature branch is when you keep development, and testing on a single branch until all work is done and only them merged to master (with no further manual tests).
That's why people say feature branches are bad, but branches per se are ok.
Who says feature branches are bad? I have never heard anyone say that.
It drives me insane, but my current boss just works out of main.
I like my PHPStorm buttons <3
A little simplistic IMO. I find myself doing a lot of git fetch upstream
, git checkout main
, git merge upstream/main
, git log
, and git rebase -i
.
Or my favourite git feature that is usually easier to do with CLI: rebasing without checking out the parent branch:
$ git fetch origin main:main
$ git rebase main
pro tip: use
git commit -a -m
No need for an additional command(git add .
)
Note that this will not add new untracked files.
my exact comment, had to scroll down so far to see this
Yeah but, git commit -am
is two characters shorter...
Except rebase cherrypick merge I didn't use anything from the long list in ny whole carrier
gst ga . gc -m "message"
Shocked to not see a single comment about git add -p
Sounds like you're working on a very simple system
I... er... use my IDE's inbuilt git tools.
100% fine
That said, it will be better for your career to know how to use git CLI because there are so many times you will need it when working with servers.
But using your IDE or GUI is still absolutely fine and can even be better in some ways.
This is very inaccurate.
The middle git commands are a nonsense sequence. Why would one be using both git merge and git cherry pick? Never use git merge if you can avoid it. Also you only have to mess with the reflog unless you fucked up bad. I guess heās crying because heās got no fucking clue what is going on.
As for the top end of the bell curve. No gitās not that easy. You need to rebase, cherry pick, and even do an occasional reset. All that guy is doing is best creating merge conflicts or worst case breaking the build.
OP doesn't get git and needs to potray themselves as 145 IQ
`git commit -am . && git push`
git merge to prod without PR š so ez
Super ultra pro hacker tip: you can use git commit -am and skip git add . this way - which saves you time you can use later for resolving merge conflicts.
far right only works if your whole team is on that level. otherwise you get stuck cleaning up the mess
git commit -a -m "" ?
Bruh. That empty commit message isnāt even human. Step it up. At least do āSome changes.ā See that proper capitalization and punctuation?? GOML
I just click the plus button, the commit button, and the push button in VSCode
palisiekurwa = !sh -c 'git add . && git commit -m \"palilo sie\" --no-gpg-sign --no-verify && git push --force && echo \"Ok, now RUN!\"'
https://github.com/jakubnabrdalik/gitkurwa/blob/master/configNSFW_PL
My 25 years of experience senior -> "just use fork dude, we're not in paleolithic anymore"
git add --all && git commit --message "$(fortune -n 72 -s)"
āTFS is easierā
āNoooo! You have to use git!ā
āTFS is easierā
TFS
is easieruses up all your fucking disk space because it stores a full copy of all branches locally
I fucking hated cleaning up after TFS.
gcaa
gpsup
Alright but git commit amend no edit is goated
I map to this graph so hard haha. 15 years in and Iām on the far right of it. 7 years ago, I was the middle part ššš
Lol why should someone expire the ref log!? It's like cutting your own safety net.
I am so glad I get to use fork so I don't have to remember any of the advanced command syntax: https://git-fork.com/
āI love my git history linearā - Any Java developer
git is the Devilās playground
I'd say the 2 most useful apart from your usual suspects are
Cherry pick and worktree
when things go bad
git reset main
git commit -am "let's try again"
git push origin --force
git add -A more than git add . for me.
$ git commit -a -m āWIPā 50 times a day
WIP too hard to type. Just do āā¦ā.
Anyone who rebases should be cast into the sea.
Worst thing: rebase and force push when working on a branch that gonna be sooner or later squashed into master.
I created a bunch of comments on a PR and guy just rebased and forced pushes changed. All comments gone, because commit ID changed....
how does that quote goes ?
"90% of your userbase won't use 90% of the features on your application"
git has a ton of neat tools that help working with it,
but for most day-to-day activities, knowing how to commit code to a new branch and push to origin is more than enough
Damn, thanks for the --autosquash, time to stop prefixing all the "wip" commits with f!
git commit -a -m git push
I am Jedi so I use more force
Been coding since the 90s. I barely know any git terminal commands. It's only when I really mess up that I start begging Google StackOverflow GPT how to do the git stuff.
Git Kraken
I use sourcetree, does it count ?
What kind of unholy strategy uses all that?
git rebase is not that hard (until you are rebasing changes that contradict each other)Ā
rebase with force push has many pitfalls. Dunno why people keep using it without just squashing stuff into master.
oh, you mean you guys don't delete the repo and push the code to a new one if there's ever a conflict?
I just rewrite, sometimes in a different language, if thereās a conflict.
Why make everything so complicated? The worst that I'll run into is a small merge conflict when pulling in changes and Ai have to do a git config pull.rebase false and manually check what I need to fix (this is why we have IDEs, people)
All these memes come down to one simple thing, really:
If it's simple, it's the first thing you learn
Then you learn about more complicated things to really take full control
Then you have to make your work accessible to others and not waste time, so you keep it as simple as when you first learned about it
Shout out to lazygit. It makes everything in the center much more user friendly!
Well if you can organize your code this well and code it in one go.
Didn't know there's a `replace` command.
I just use lazygit now. I forgot most git commands aside the main 3
So what does the guy on the left do when his branch is behind origin/main? What does he do when there is a merge conflict?
i used to use those console commands, but now i do everything in intellij idea
git commit -a -m āminor changes; git pushā
Idk I just use the buttons in my IDE...
If Iām spending time fucking around with git commands, Iām not writing the code for the app Iām supporting. Git interactions should be simple, pull/push, branch, merge, stash, commit. They should also be easy. Thatās why I actual prefer a GUI like SourceTree. I know I can do more complex things on the command line, and when I need to I do, but most of the time I just want to see what Iām working with and get back to writing code. But ultimately you do you.
I might be on the left, but I canāt be convinced git cherry-pick is a real command.
I use GUI for Git
I had a manager once who insisted we put in extra effort to keep the git history clean. No reason. He just liked how it looked.
Pound sand, Cody. Your opinions were trash.
Or: [ Commit button ] click 1, [ Push button ] click 2.
git pull --rebase
git pull, git add, git commit -m, git push -u origin main. š£ļø
Proud to be on the left side of the meme (except pull, rebase, commit message, force push)
My rule of thumb is - do whatever the fuck you want in your branch but when you merge to master, squash the commits
git reset --soft HEAD~n
is the best way to squash n commits and I'll die on this hill.
Rebase from develop/master should be mandatory before doing a PR.
One commit features (using ammends or rebase -i) should be mandatory before doing a PR
ff-only merges, at least between master and develop should be mandatory
pulling should be banned (git fetch + rebase is miles better)
git add -A
I've been using git regularly for ten years now, I've still yet to ever hit the middle part of the curve.
Edit: with proper branching, though
Git ignore plz
which one am i?
And my dumb ass is alwasy using git add -A
NGL. This is where your AI terminals come in pretty handy. I've been using the add, commit, push trio my entire career. When I need anything more complicated I used to look it up online (takes a few minutes) but now I just tell my terminal to do it and it does.
AI is for the weak
Refer to the meme. Strong jr dev energy you got there!
Git is more difficult than JS tbh
If only I could just teach 3 commands to someone and they never call me again...
This stuff only works if you work alone... I don't see the point of the meme. People who can't work with others are not on the right side.
I always laugh at how true this meme is because itās so true š I did these exact mistakes
Are y'all really manually typing all these git commands all the time? Every modern IDE has a git integration. Makes all of this pretty easy and quick. Even faster if you're using the keyboard shortcuts
Not all those commands, but yes. My IDE has git integration like you said but I prefer to do my gitting in the command line.
It could work fine for the basic flow, but I do enough non-standard stuff that git integrations feel stifling.
most git GUIs do not give you access to most of the commands in that list
yes, I type them every time. I know what I want to do, and I know what each option does, so I know what I need to type.
and I have aliases for the commands I use often. like sup
for submodule update --init --recursive
, because I work with submodules a lot.
At that point why not just make a bash/shell file at that point if you are writing the same 10+ commands over and over for every git usage
that's what git aliases are for.
But doesnāt a git alias only shorten a single command not a series of commands or was I unaware it can shorten a series of commands
by prepending ! you can start doing shell commands. so you can use && or take arguments.
an example alias i have: hotfix
for !git add . && git commit --amend --no-edit
an example of taking arguments: dry-merge
is !git merge --no-commit --no-ff $1 && git merge --abort &&:
usually tho, you only need to shorten 1 command. like i have sup
for submodule --update --recursive
Iāve yet to use a bit gui that doesnāt have some glaring hole that requires stepping back to the cli. Even source tree.
as if typing commands is some laborious task lmao
Atuin
i use vs for that. yeah, iām the guy on the left
How to tell if your ide has prebuilt git integration. Did your project generate with a gitignore file? Perfect it definitely has git integration. I canāt think of a single ide that doesnāt generate a gitignore file either.
I like zsh with git plugin.
ga . gc -mĀ gp
Most of them, yes. I like to know the commands so I can work even on another computer.
At least the usual pull, add, commit, push, rebase is something I use very often.
When it comes to cherry-picking, I as the brits.
Just joking, I use girk for that.
And for switching between local branches, I use the function of intelliJ, but I am quite sure that it is
git checkput [branch name]
SVN is better. No hassle with branches and all that. The only way Git would be better is by force pushing all changes to the master branch.
You're fired
git commit --amend
git push --force
Keeping the history clean by having only one commit š
Called 'update'
Welcome to gerrit
Even better: git commit --amend --no-edit
I used to alias this one, I called it git apend (or append? Idk)
That's
gcane
on my machine. Big fan of keeping branches clean, rewriting history is encouraged in our shop, as long as you're the only one working on your branch.ĀWe just squash merge, so it doesn't matters how messy your branch is.
Sure makes it easier. But I personally find it obscures too many details in history. I'd rather have a more detailed git blame.. .Ā
I have it aliased to "git whoops". As in "whoops I forgot to remove that debug print".
i have a bunch of aliases on my git config, and `git amend` is the i used the most :)
i also have a `git nuke` command, which removes every branch but main/master/stage
and a `git prune` which lists the command i need to run to remove all merged branches from origin (still need to copy and paste them, because no fucking way do i trust git NOT to mess this up)
Or of you're feeling fancy,
git push --force-with-lease
No. That is for children. Big dogs dgaf about with-lease.
"I
push
now! Good luck everybody else!"--amend --no-edit
git add -u && git commit āamend āno-edit && git push -f origin HEAD
I do a bunch on my own branches when I've not yet set up a PR for review. I like to do granular commits and sometimes I miss a file that belongs to a commit I just made.
This is the way.