With git/github I really only pull and push. I don’t really use any of the other features. Same for the kids on my robotics team. The only thing I have taught them is pull and push. The kids do a pull at the beginning of practice and a push at the end. Yet sometimes I see this in the commit logs. Why are these merges happening? Even I have some merges and I know I didn’t do anything differently. Should I be concerned? We are doing all of our git/gihub work in VS code if that matters.

  • al4s@feddit.de
    link
    fedilink
    arrow-up
    22
    ·
    1 year ago

    If your local branch and the branch on GitHub diverge, they need to be merged. If you pull using the console it will tell you that, apparently VScode does this automatically?

    Anyways, nothing to be concerned about. If you’re annoyed by the merge commits, you can configure git to “rebase on pull”, google it, you’ll find instructions pretty quickly.

    • CMahaff@lemmy.world
      link
      fedilink
      English
      arrow-up
      16
      ·
      1 year ago

      To expand on this a bit, git pull under the hood is basically a shortcut for git fetch (get the remote repository’s state) and git merge origin/main main (merge to remote changes to your local branch, which for you is always main).

      When you have no local changes, this process just “makes a line” in your commit history (see git log --graph --decorate), but when you have local changes and the remote has changed too, it has to put those together into a merge commit - think a diamond shape with the common ancestor at the bottom, the remote changes on one side, your changes on the other side, and the merge of the two at the top.

      Like the above comment says, normally this process is clarified at the command line - VSCode must be handling it automatically if there are no code conflicts.