0

new to git.

Say we have a main branch and my user branch is called mybranch.

When I'm at work, I have my VSCODE opened with mybranch as the active branch -- and I have the same setup at home.

While at work, when I write code inside mybranch (whether its new/deleted/modified files), and they are uncommitted, how can I then share all those changes when I'm working from home on my home computer?

  • 4
    Commit them, push the commits to a remote (which could even be your home computer's repo). If the remote is not the home computer, whilst on the home computer, pull the commits. – evolutionxbox Jul 21 '22 at 13:59
  • 4
    Read the book ["Pro Git"](https://git-scm.com/book/en/v2). It is a good start to work with Git. – axiac Jul 21 '22 at 13:59
  • @evolutionxbox how would I do that? When I commit, it currently sends my changes as a pull request to be `merged` into `main` – Everything Digital Jul 21 '22 at 14:01
  • _"how would I do that"_ - `git add ; git commit -c ; git push` – evolutionxbox Jul 21 '22 at 14:03
  • 3
    You need to understand the difference between the (I assume) three different repositories: the one of record in GitHub/GitLab/whatever, the clone on your work machine, and the clone on your home machine, as well as how tracking branches work. All of these branches exist: `mybranch` in the repository of record, `origin/mybranch` and `my branch` on your work machine, and `mybranch` and `origin/mybranch` on your home machine. You need to understand how distributed version control works in general before you can start to distinguish between all these branches. – chepner Jul 21 '22 at 14:04
  • Thanks for that, any resources in particular that would help break this down? I've been going through the git docs but haven't yet been able wrap my head around it. – Everything Digital Jul 21 '22 at 14:19
  • 1
    @EverythingDigital: the second comment on this question has a link that links to exactly that resource (and it contains the full content of the book, it's not an Amazon link). – Joachim Sauer Jul 21 '22 at 14:24
  • 1
    https://stackoverflow.com/search?q=%5Bgit%5D+for+beginners – phd Jul 21 '22 at 14:37
  • 2
    @EverythingDigital "it currently sends my changes as a pull request" - neither git itself, not common web interfaces like Github, Gitlab, and BitBucket will by default open a branch as soon as you push it to the server; that's a separate action you have to take. If that's happening, it's some specific tool set up by the project you're working on, and you need to discuss with the project team what they expect, because **having multiple work-in-progress branches, both locally and on shared servers, is a normal part of most git workflows**. – IMSoP Jul 21 '22 at 14:52

0 Answers0