programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Mac to Git ·
edit-2
1 year ago

Every git command I use (Cheatsheet)

message-square
12
link
fedilink
103

Every git command I use (Cheatsheet)

Mac to Git ·
edit-2
1 year ago
message-square
12
link
fedilink
every git command I use
programming.dev
external-link

https://wizardzines.com/comics/every-git-command/ Not OC

alert-triangle
You must log in or register to comment.
  • sovietknuckles [they/them]@hexbear.net
    link
    fedilink
    English
    arrow-up
    8
    ·
    1 year ago

    geordi-no git add

    geordi-yes git add -p

    Otherwise, I would be staging the whole file without looking at what I’m staging first

    • GarytheSnail
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      How do you run unit tests for commits if you’re only adding bits of the file?

      • PoolloverNathan
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        You can do git stash -k before running tests.

      • sovietknuckles [they/them]@hexbear.net
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        You’re never actually “adding” the whole file unless it’s a brand-new file, git add my-file just adds every patch change for that file without confirmation.

        Using git add -p my-file, the same hooks will run as if you staged and committed all changes to my-file.

  • Scratch@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    ‘git checkout -‘ to toggle between branches ‘git checkout -b branch_name’ to create and switch to a new branch.

  • tuto@lemmy.world
    link
    fedilink
    brezhoneg
    arrow-up
    5
    ·
    1 year ago

    Obligatory https://ohshitgit.com/

  • GarytheSnail
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    I use git commit --amend --no-edit often.

    Like if I forget to run a formatter before I commit and the build complains just for that.

    git add -u
    git commit --amend --no-edit
    git push -f
    
  • JoYo@lemmy.ml
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    1 year ago

    before every git command i use:

    tar -czvf my_directory.tar.gz -C my_directory .

  • ShrimpsIsBugs
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    I still haven’t adopted to this git switch thing

  • Lucien [hy/hym, comrade/them]@hexbear.net
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    git reset --hard

    😬

    • comrade_pibb [comrade/them]@hexbear.net
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      i dun goofed

  • MüThyme@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    deleted by creator

  • lseif@sopuli.xyz
    link
    fedilink
    arrow-up
    2
    arrow-down
    2
    ·
    1 year ago

    make sure to run

    cd ..
    cp -r my-project my-project.bak
    cd my-project
    

    before running each command :)

Git

git

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Resources

  • Official Git project site
  • Pro Git book

Rules

  1. Follow programming.dev rules
  2. Be excellent to each other, no hostility towards users for any reason
  3. No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 4 users / day
  • 50 users / week
  • 84 users / month
  • 457 users / 6 months
  • 942 local subscribers
  • 3.24K subscribers
  • 248 Posts
  • 1.03K Comments
  • Modlog
  • mods:
  • Ategon
  • canpolat
  • Jason Novinger
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org