M
M
Mubat2016-11-23 23:18:14
git
Mubat, 2016-11-23 23:18:14

How to work with Git on multiple computers on a single commit?

I have a work and home computer.
Sometimes it happens that at work you are working on a feature/fix and you don’t have time to finish the work to commit. And after work, I would like to finish work on the feature / fix.
But the bottom line is that the unfinished part does not pull on a full-fledged commit. I would not want to make an intermediate commit from a working computer so as not to clog up the history. And at the same time, playing with transferring changes to a USB flash drive and back on a home computer does not look very attractive.
Maybe someone will tell you how to get out of this situation, so to speak, best practices.
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
abcd0x00, 2016-11-27
@Mubat

And after work, I would like to finish work on the feature / fix.

It's terrible, of course, that you're doing work after hours. So you can become a workaholic (life = work) and get burnout (depression).
If you want to finish the work periodically, you must have a cloned project on your disk (on a flash drive, for example). It can be connected to the main project as a remote source under some name. It will turn out as if you have it, as it were, on github, but it will be on a flash drive and you can push it there and download it from there, as from a regular remote repository.
And to transfer uncommitted changes, use a diff file: you do git diff, but you send the output to a file, and then you can transfer this file to another repository, and then do git apply with it in another repository and these changes will appear there also in an uncommitted form.
And the fact that you write that you have one big commit - it shouldn't be like that. There must be a branch for some feature, many small commits are made to it, and then this branch is merged without a fast pass (this is when the merge commit is made anyway). And in this merge commit, all the information about the feature is written.
And the commits themselves in such a branch should not depend on each other (this is not always possible, of course), so that when you cancel one change, you do not need to cancel the rest.

G
GavriKos, 2016-11-23
@GavriKos

branch per feature approach will help you. You make a brunch, commit at least every line into it, then merge into the main brunch. Bottom line - the main brunch is clean.

A
akzhan, 2016-11-24
@akzhan

commit as much as you want.
then use "git rebase -i the commit number that spawned from" to merge all the commits into one or as many as you need (anything else will be gone).

A
Anna Buyanova, 2016-11-24
@LightAlloy

As I understand it, we are talking about not making an intermediate commit, incl. and in the feature branch.
If you don’t want to commit at all, you will have to somehow move the code yourself - through an external medium or some kind of dropbox.
You should also keep in mind the recommendations to commit often (for example, https://sethrobertson.github.io/GitBestPractices/#...
It might be worth breaking a feature into several commits.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question