Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Switch workspaces (computers) without committing

Is there a way to apply a diff patch or similar without doing a commit/checkout?


My situation: I often switch between computers when working, and my commit history has a bunch of "switching machines" messages.

My initial guess is that this could lead to other troubles, but thought I might ask in case there is a suitable solution or workflow for this situation.

Edit - clarification: Computers are networked.

Edit - deeper thoughts: Now that I think about it, this would cause some bigger problems with the revision history by not going through Git. But perhaps there is another workflow solution I haven't thought of?

like image 653
Peter Peterson Avatar asked Oct 20 '25 00:10

Peter Peterson


1 Answers

One of the nice things about git is that committing is separate to publishing. This lets you commit work-in-progress commits without having to publish them and having 'messy history' on record for evermore.

My suggestion would be to continue to do the commits when switching workspaces, as that gives you a solid point-in-time backup, and removes any reliance on the workspaces being networked all the time (thus enabling efficient working with a laptop for instance).

To solve the solution of the untidy history due to the 'switching workspaces' commits, I would suggest that you work on topic branches, or 'dev' branches, and when a feature is finished squash all the working commits together and then merge the newly tidied history onto the master branch.

Running git rebase -i master on your topic branch will let you group and squash your commits to get tidy history before merging to master and pushing to 'final history'.

like image 182
tul Avatar answered Oct 22 '25 03:10

tul