Daniel
Daniel

Reputation: 1575

Git: Working on different machines

I'm using git for a while. In most project, I'm the only developer but I work on 3 machines (work laptop, personal laptop, Desktop machine). I tend to do a lot of commits, even if the feature I'm working on is not complete. I often write commit comments like "Saving current work".

This is mainly to work on a different machine later on. I think this is not the ideal solution. Would it be better to create branches and upload them to the server? I figured out that branches seem to be local, but I need them on the server in order to be able to check them out on a different machine.

Or is there even a better way?

Upvotes: 1

Views: 258

Answers (2)

CharlesB
CharlesB

Reputation: 90276

Sounds like you'd want feature branches. You can keep your "WIP" (Work in Progress) commits in it, to share the code changes between your machines, and clean the history of such branch when merging it back to master.

When switching machines you just pull the feature branch from the machine you were working on, and continue to work. You can even rebase --interactive on it to keep a clean history during your work, and then reset when switching machines, as long as you keep all this stuff in a separate branch.

This way master stays in a clean state, and you do all your in-progress sharable stuff in separate branch.

Upvotes: 3

lijinma
lijinma

Reputation: 2942

I think it's not a big deal.

You just worked in 2 branches:

  1. work
  2. master

in work branch you can commit anything even not complete.

But, after that, you need to use:

git checkout master
git reset --soft work 
# reset --soft is really helpful.

Then formally commit your work again.

Upvotes: 1

Related Questions