7
TheYarbs
183d

Anyone got any advice on learning Git commands? Or anything that helps them remember commands?

Comments
  • 8
    Using them a lot
  • 2
    @jestdotty I was worried that would be someone’s answer LOL. But, thank you.
  • 3
    git commands are just like any other. Use them and learn over the time
  • 0
    Use a GUI git client like Fork, then you don’t need to remember the CLI commands.
  • 4
    git clone
    git fetch
    git pull
    git checkout develop
    git branch my-feature
    git checkout my-feature
    git status
    git diff 'feature.java'
    git add 'feature.java'
    git commit -m 'added more bugs'
    git push
    git reset --hard

    that's pretty much all I use all the time. Sometimes I do more, like merge/rebase, maybe smth else, but these are rare birds and I go to docs when I need it. Or, you know, use github/gitlab UI :)
  • 2
    just... don't _be_ a git and you'll be fine.
  • 2
    Just store your most used commands on Notes if you’re on mac or on sticky notes if using PC.
  • 0
    Get the best editor (for Mac). Git source controls built in.

    https://nova.app/
  • 0
    Unless you'll be doing hardcore maintenance and/or have extremely complicated development flow, there are like 5-10 commands you will use - and they all are named after what they do. If you're afraid of learning that, maybe you should rethink your choice to go into development.
  • 4
    git gud
  • 3
    Ignore what people said about IDE and other tools. It's very good to get the basic concepts down IMO. This site is interactive and put well together.
    https://learngitbranching.js.org/
  • 0
  • 2
    Git status is your best friend. It usually tells you what command you should do next.
  • 0
    @netikras i still cant understand the difference between got fetch and git pull. Or i dont know when to use one over the other, in which situation
  • 2
    I'd say the most important thing is learning how to write good commit messages, and structuring your work into meaningful commits. I hate seeing PRs with a single commit titled '<ticket number> Done', so unhelpful.
  • 2
    @b2plane fetch just gets you the info of what stuff there is to pull. Pull pulls that stuff into your current branch.
  • 0
    @Lensflare so fetch is like a log?
  • 0
    @b2plane

    fetch -- pull metadata of all the branches from the remote

    pull -- use the metadata on the current branch to pull the actual data

    I might be wrong.. But it seems that fetch doesn't fetch the data/diffs - instead, it fetches information _about_ ALL branches, how far behind are they, etc.
  • 3
    @netikras not quite, if I'm remembering correctly 'merge' would just use existing metadata to update the branch. 'pull' is equivalent to running 'fetch' and then 'merge', i.e. fetches the latest metadata from remote and then uses that metadata to update your local version of the branch.

    I'm prob just being pedantic though.
  • 2
    One command that I find quite useful is updating a local branch without checkout - I was getting bored of checking out an old version of a branch, then running 'git pull' to update the local branch (especially if I'd just merged a PR to master and was switching from my feature branch to master, so technically no file changes would be necessary).

    git fetch <remote> <srcBranch>:<destBranch>

    https://stackoverflow.com/a/...
  • 1
    @fruitfcker im gonna give those links to the babydevs... one of them had never encountered a non-android computer before... i may have intentionally left out most of the gui functionality when introducing him to shit and just given him a big list of CLI for windows or linux. Then made him figure out the functionality of each and the way to achieve the same thing via the other CLI.

    ...he'll thank me in the long run.
  • 1
    @netikras i totally screenshotted that post for babydevs. Thanks
  • 0
    @tosensei lol! ...first time I mentioned "git" instead of "github" to a certain babydev he looked up the word "git" (I have a general policy of 'if you don't know a word/term, you better look it up') and found some odd definition I was unfamiliar with.
  • 3
    @b2plane

    Seriously?

    You bitch and bitch endlessly about not getting a job... Get one on DevOps, of all fields... And you don't know the difference between git fetch and git pull?

    In past posts I told you you might be underqualified for your expectations.

    You are underqualified even for entry jobs.

    As I've told you many times before, before aiming for the moon, go back to the basics. Trust me, you need it bad.
  • 1
    @CoreFusionX glad that someone, with enough balls to voice it, has the same opinion on b2plane as i do... though I append that he likely needs to learn some decorum and also not charge in head first to shit before understanding the basics so he can actually be productive instead of troubleshooting and ranting about the completely avoidable issues he encounters.
  • 1
    @alturnativ though I'm definitely aware of the proper things i should be doing... i begrudgingly appreciate your comments. They make it harder to lie to myself about the example i should be setting for the babydevs.

    I'm much more used to solo coding things that arent intended for modification or collaboration. But since I willingly started this tech/blockchain startup and, despite my innate preferences, am 'the boss, creator, current primary dev' I gotta get my shit together or it'll negatively effect any employees, supporters, etc.

    I know it's ridiculous, but I still have that overall 'but I don't wanna!' mindset lurking around. *sigh*...i totally need a manager. Unfortunately, I haven't been able to think of any logical way to hire someone to manage/babysit me... I don't like being self-imposed responsible.
  • 1
    @awesomeest

    Mind you, I've told him this *many* times before, but I'm past the point I'm gonna help him.

    If he chooses to be the ignorant fool, he gets what he deserves, no matter how much he whines.
  • 2
    Understand how it works on a fundamental level. Don’t just use a GUI and think it’s just magic every time you click a button. There’s lots of online tutorials that help you understand how the branching, pointers, etc… and can explain ~visually~ a lot better than GUIs can.
  • 0
    @CoreFusionX yeah... you should look at the rant/question i had posted about an issue with a certain babydev... he starts complaining that i hired someone who never saw a non-android OS and how "disrespectful" that type of shit is to HIM.

    I have very abnormal HR practices... but I'm more known as an international business consultant than dev (at least to people who don't know my unpublished history... been technically a pro fullstack (html/css/php/dbs/simple shit then) from age 8)... so technically I'm an expert in HR and a handful of other business shit (also made/sold a few successes... got bored).

    Simply put, I hire on potential and eagerness/passion... especially at the start. I have the skillsets i need to hire for so I'll glady take an eager to learn total newb over a uni grad that thinks they know shit any day

    ...like an 18yr old burmese kid i supplied with tech & 'forgot' mentioniing most GUI shit exists... giving a pile of linux and win/dos commands to research/learn
  • 1
    @jestdotty guess we have some shit in common... ive fucked up my win10(custom beyond what windows allows) laptop's keyboard setting in mysterious ways sooooo many times, even needing to reset shit, when using it for remote to our rhel9 server... some windows key combo gives weird behaviour. Since i use rustdesk often (to update the live charts, not for linux gui...fk that) im not totally sure what alchemy, win/linux common/custom, is responsible.... and cba to figure ot out when i need to just stop conflating win vs linux combos.

    It's extremely local... currently 3ft away. Has a tv screen display (showing crypto charts-- extreme adhd multitasker) and I have great additional keyboards... but only 1 functional hand so my keyboard usage is highly specific.

    Im strongly considering just making an activatable profile mod that basically just aliases my windows and rhel combo functions to the same hotkeys/combos.
  • 0
    If you know these, you’ll be good for most dev roles:

    git clone
    git pull
    git add
    git commit
    git push
    git rebase
    git revert

    Edit: git stash
    Edit2: git checkout

    Damn i need coffee
  • 3
    @jestdotty ew ew ew! Why force someone away from what they're actually doing to go look at the ticket? Context-switching is a productivity-killer, it's much more helpful to be able to see directly from the commit message what was being changed.

    I include the ticket number in all of my commits, but that's not the ONLY thing I include. Depending on the complexity and scale of the commit, my format is usually something like:

    "<Ticket ID> <Ticket Summary>

    <Extra description>"
  • 0
    And the other benefit of having meaningful commit messages is that it makes code review much easier - if I'm working on a complex ticket with many changes, a reviewer can review my PR commit-by-commit and verify that each commit is doing what it's supposed to, as well as then being able to look at all the commit messages to verify that the bigger-picture logic also makes sense.
  • 0
    From a code review context, maybe another way of looking at it is: "the reviewer should be verifying that your code does what you say it should, not figuring out what it should be doing in the first place".

    The 'you say it should' part is the commit message :)
  • 2
    I'll try and dig up some examples once I'm back at my work machine. If there's just one commit in question, sure, going through to the ticketing system is no big deal, but what happens when you're scrolling through commit history with multiple commits? Just seems like an unnecessary exercise that could be avoided if the author of the commit wasn't being lazy.
  • 1
    @alturnativ @jestdotty
    Thank you both for making me appreciate never needing to deal with that shit. #blessed #irony
Add Comment