(or, depending on configuration, maybe you'd need git pull origin or even git pull origin master). So typically you'd first get the changes into your local master git checkout master Now, if you want the origin/master changes reflected in multiple branches, then you have to perform multiple merge (and/or rebase) operations and a given pull only does one. I use pull quite a bit, but only for its default behavior in repos whose configuration/branch setup is "typical". Which is a little more explicit (so less dependent on configuration details, etc.). It's basically a shorthand for git checkout my_branch (Some people seem to think this default behavior is all pull does, and that can get them into trouble.) So if you want to integrate the remote master's changes into your branch, you can do git checkout my_branch If you want to affect both, you can (see below for more on that).Īlso, you can tell git what changes to incorporate into the current branch, or if you don't specify then it will look for a configured default corresponding to the current branch. This, of course, is the point of branching - changes to one branch don't automatically affect the other. If you check out your branch and then pull, the changes will be incorporated into your branch (but not master). If you check out master and then pull, the changes you pull will be incorporated into master (but not your branch). The first thing to understand about pull is, it updates the current branch. You can ignore this advice if you want, and many teams do, but one of the reasons the branching model linked above is so popular and successful is that it's designed to work with continuous integration, not against it.What git will do depends on the exact command you issue, and also on your git configuration. tons of features being worked on at once) then you'll see better results from splitting it up into separate autonomous components than you will from papering over the problem with source control. instead, it fetches forcefully but does not. If developers can't successfully merge into this branch (which only needs to build, not run flawlessly) at least once a day, then you have a quality/discipline problem and not a revision control problem covering it up by using non-integrated developer branches only defers the problem, and by doing so, actually makes the eventual merges a lot more painful and unstable than they really need to be.įeature branches aren't the worst, but IMO very few projects are actually big enough to warrant them if your project is very large (i.e. Now you must be thinking, what is git pull -force then it feels like it would help to overwrite local changes. If you absolutely must defer integration in order to protect the stability of the master branch, the typical, proven model is to use an unstable branch - sometimes called a development branch, as described in A successful Git branching model. Just pull, merge locally, and run commit tests before you push, it's simple. Git handles merges so effortlessly most of the time that remote developer branches are just unnecessary overhead. I'm currently part of a group of about 35 contributors divided into 4 separate teams, most people check in at least 2-3 times a day, some people 10-15 times it's unusual to see builds broken and extremely rare for them to stay broken for more than a few minutes. Most organizations should be integrating very frequently - as in, several times per day. It especially doesn't make sense with git, because every developer already technically has his/her own repository. Unless you're actually working in a geographically distributed team with a need to "gate" changes from outside developers, the branch-per-developer model really doesn't make much sense. I don't want this to be a rant about why you need CI, but it's clear from your question that you know you aren't integrating your changes often enough, so IMO there's no point in dancing around the issue. These teams generally try to use developer branches as a way to protect the stability of the mainline, and the result is - typically - a long and very painful merge period before the release, followed by an even longer and more painful stabilization period, which sometimes doesn't happen until after the release. Teams and organizations which do not have continuous integration and a track record of instability in their deployments, or worse, instability in their builds. This makes life more difficult for contributors, but much easier for the maintainers, which of course is exactly the point, and this is a very successful model on GitHub. The open-source community, where these branches are actually repository forks, so that project maintainers can lock down access to the master repository and require integration through pull requests. I've seen developer branches used in two main scenarios:
0 Comments
Leave a Reply. |