I’m doing a solo coding project for work. It’s a tool that you interact with similar to npm or cargo, where you can create a new workspace, run / test etc. Importantly, you have to be in the working directory for the commands to work…

Yesterday I decided to go home early to do remote work at home. Before i left i quickly did git add ., committed and pushed. I turned on my computer this morning, ran git pull, and noticed that… only some files got pushed, but more importantly none of the code i wrote yesterday made it through. Yup, I was still cd’d into my workspace folder and not at the project root, so I only committed the mock workspace folder 😄

Luckily i didnt write or change much this time, but lesson learned: git add -A or git commit -am '...'

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

      Or use tig. It’s a great CLI tool to view git status, stage/unstage, and view history. And I never really hear anyone talk about it.

  • Synthead@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    1 year ago

    When staging files to commit, you can use an interactive patch:

    git add -p

    Before you make your commit, you can inspect what’s being committed:

    git diff --cached

    If there are things you want to remove, you can do so with interactive patches, too:

    git reset -p

    You can also pass directories or files to any of these commands to include a subset of your project in the command.

    • tunawasherepoo@iusearchlinux.fyiOP
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      omg these are great commands, thanks for sharing :)

      git is definitely a weak spot for me in general, there’s a lot of commands and similar commands, so my approach until now has been to forget they exist haha

      • Synthead@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        You bet! You can always check the man pages by adding a hyphen between the git commands, too, like so:

        man git-diff

        man git-add

        It’s exhaustive, but you can search the page with slash (/) 👍

        • tunawasherepoo@iusearchlinux.fyiOP
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          honestly, i check the manpages for anything else but i never have with git 🤣 however I didn’t know how to access the man pages for subcommands, thanks!! :)

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

    Even better, just choose exactly which files to add to a commit, and keep the commits small and meaningful units of work! If you never use the shorthand, you won’t have this issue, and your commit history will be easier to understand and expand upon!

    • tunawasherepoo@iusearchlinux.fyiOP
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      This is what i should be doing :)

      I have been justifying it away though cause it’s early stages of the project so it’s hard to get my bearings. But the dust is starting to settle enough now that I can probably think about committing units of work rather than this daily snapshotting ive been doing

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

      In my 20 year career, I’ve never had a single position where I could ssh into my work machine from a remote location.

      I would say that if you have been able to do that, it’s exceptionally rare, and there are a number of security red flags of your organization is allowing that.

      • NostraDavid
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Work laptop + VPN should take care of most security stuff, no?

        Being able to SSH remotely without VPN would be certain red flag.

        • atheken
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          Even with VPN, remote connections are frequently partitioned from on-premises machines, either on purpose, or because the network is large enough to require different subnets.

          Having VPN definitely makes it possible and far less risky, but it’s still not really a guarantee, and that could still indicate a more relaxed security posture.

          No judgement, it’s just not typical in a lot of environments.