My team and I are new to Git; we have used CVS so far. We have a remote repository and each one of us has his own repository. Each one of us is working on a feature or bug, but some of us may work on different parts of the same feature.
When one is done they commit and push their changes. Another programmer may want to use that code (for example, if one is working on BL, and another one on UI), but without committing anything as the code may not even compile yet or the working directory may still be dirty.
So far I've only found out a suggestion to use stash, but we find it uncomfortable. We want to pull the code from the remote and simply get it merged with the uncommitted code, but as far as I understand Git, this is probably impossible.
What do you think would be the best way for us to work with the remote?
Commit early, commit often Git works best, and works in your favor, when you commit your work often. Instead of waiting to make the commit perfect, it is better to work in small chunks and keep committing your work.
When comparing Git pull vs fetch, Git fetch is a safer alternative because it pulls in all the commits from your remote but doesn't make any changes to your local files. On the other hand, Git pull is faster as you're performing multiple actions in one – a better bang for your buck.
If you have uncommitted changes, the merge part of the git pull command will fail and your local branch will be untouched. Thus, you should always commit your changes in a branch before pulling new commits from a remote repository.
You are suffering from CVS/SVN habits in your work-flow, and especially from the "big patch" mindset.
Git has a very cheap branching model and interactive staging. The upshot of this is that you should be working on feature branches, and treating your non-integration branches as patch queues.
So, instead of "code, code, code, code, push, pull, merge, scream" you should do something more manageable:
git add -p
is your friend.If you start treating Git commits as patches, and branches as patch queues, you'll end up with a work-flow where people can cherry-pick or merge small change-sets among repositories without getting a migraine. The Git branching model makes it easy, but it's up to your team to break down the work into right-sized pieces.
As long as you are not pushing your own code, you can commit, and then git pull
.
A commit will remain private to your repo until your next push.
So you can work on the same 'feature
' branch, and still benefit from the push of your colleague.
But if you must also publish your work, then you can use a 'developerX_feature
' branch, in order for you to push your own branch, and for other to fetch and then merge your branch to their own 'developerY_feature
' branch in their local repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With