Are there any better methods than stash to use git-pull when our workflow involves a lot of uncommitted code?

My team and I am new to Git; we have used CVS so far. We have a remote repository, and each of us has its own repository. Each of us is working on a function or error, but some of us can work with different parts of the same function.

When everything is done, they commit and push their changes. Another programmer may want to use this code (for example, if he is working on BL and the other in the user interface), but does nothing, because the code cannot compile yet or the working directory may still be dirty.

So far, I have only found an offer to use the cache, but this is inconvenient for us. We want to get the code out of the remote and just combine it with the non-committed code, but as far as I understand Git, this is probably not possible.

What do you think will be the best way for us to work with the remote control?

+6
source share
3 answers

Problem

You suffer from CVS / SVN habits in your workflow, and especially from thinking of the โ€œbig patchโ€.

Decision

Git has a very cheap branching model and interactive staging. The result of this is that you have to work with function branches and treat non-integration branches as a patch queue.

So, instead of "code, code, code, code, push, pull, merge, scream" you should do something more manageable:

  • Send a lot. Create a branch for each mini-function or shift.
  • Capture tons of small atomic changes in your private branches. git add -p is your friend.
  • Restore your private branches against your integration branch before joining it.
  • Click on your integration branch every time you have a full set of changes or the completion of a function.

If you start to treat Git as a patch and branches as queues of patches, you will get a workflow in which people can select or discard small changes between repositories without receiving migraines. The forked Git model makes things easier, but it depends on your team to break up the work into pieces of size.

+17
source

Until you push your own code, you can commit it and then git pull .

The commit will remain closed to your repo until the next push.

git push

So you can work on the same feature branch and still benefit from the push of your colleague.

But if you also have to publish your work, you can use the developerX_feature branch so that you can click your own branch, and for others to select, and then combine the branch into your own developerY_feature in your local repo.

+6
source

Use branches! You can create a branch, commit changes to this branch, click on this branch and other people, then get this branch and switch (checkout) between the branches (even offline). This will not affect your main stable branch (master).

0
source

Source: https://habr.com/ru/post/918863/


All Articles