tags:

views:

107

answers:

4

Hello all, I'm a newbie in git world, i want to ask how to solve my workflow problem, basically I have 2 computer, one in office and one in home, and I'm also have a vps working as my git shared repository. When I work at office, I have unfinished code, and I want to continue my work at home, so usually I'll commit first at office and push my work into git shared repository, and after that I'll pull back at home and continue it.

But sometimes, I just didn't straight go home, and in the meantime, one of my co-worker, pull the code and work with it, and he just yell at me because I committed broken code. So my question is, how do I change computer without committing but I still get my unfinished work ?

+10  A: 

Do all your work on your own branch, let your coworker know not to pull from that branch. This could get messy if you've got lots of developers, but with only two people it shouldn't be a problem at all.

kubi
working in your own branch also allows you to reset/rebase/delete commits—whatever you want to do
knittl
That doesn't matter. You should never reset/rebase/delete a commit that you've pushed, even if you're sure you're the only one using it. If you haven't pushed, you can freely rebase, etc. anyone else's branches without causing any trouble.
kubi
A: 

As kubi said, use a private branch. If you don't want to push broken code into the repository at all, you can email yourself the changes as a patch (use git format-patch), apply it at home and work from there (with git apply)

Also remember that you can use git commit --amend to overwrite a "half baked" commit with a proper one, read to be pushed to the shared repo.

Michał Bendowski
+2  A: 

When I work with more then myself at a project, I use my own branch. So if I have code that is not finished yet, I commit and push it to my own branch. When I think this code is ready to use I commit it to a common working branch. After testing it here we merge it to the master branch.

Example:

Master branch: Tested by everyone. WIP branch: Common work in progress branch, branch everyone can use the code, and test it. WIP-Bright: My own branch WIP-someone: Branch of someone else.

Using this git cheatsheet make working with git a lot easier.

Bright010957
A: 

If you can't setup network and repositories so that you can at home pull from work and push to work (see section ' How would I use "git push" to sync out of a host that I cannot pull from?' in GitFaq page on Git Wiki), and neither can you setup your own bare 'publishing' repository used by you to excahnge between work and home, take a look at git bundle, which is meant for off-line (sneakernet) transport.

This might be not a direct answer to your question, but I hope that would help.

Jakub Narębski