With a rebase, those intermittent commits are almost useless, as the repo doesn't look like it did when they made that commit. To sum up, don't subvert git just because you want to see a straight line in your commit graph. It's not worth it, and it is ultimately a lie.
It's a popular misconception that git rebase destroys history. It rearranges it into something else. Remember - you're only rebase ing your own code, often on a feature branch. It's your own history until you push it somewhere. If you don't understand that you're going to have a bad time with any DVCS and have ugly, hairy history that is basically unreadable to anyone bisecting, looking for bugs. It's your option feature branches with merges that's available to SVN users.
Making history useful is something available only to DVCS. It's pretty clear it's local. In fact - you should do it. Are you talking about people pulling using public remote branch resolving pull requests? Pull requests should demand that the said code apply in a clean manner demand rebasing PR code against current HEAD and use merge -no-ff option to indicate resolved request.
Well I'm embarrassed. I had to facepalm myself when I realized the issue I was seeing was from people doing a rebase of master from a branch and then pushing which is where issues really crop up from the history being changed.
So you're quite right. Can I just blame it being too early in the morning ; I'm going to retract delete my above comments. Pull with rebase wont push changed history unless you have multiple remote repositories in which case you should know git better. You never have to use rebase, you can always do a revert commit.
But it makes your repositories unreadable and sharing code so much more difficult. If you are working in a branch with a friend, a think git pull --rebase is the must. Personally, I follow a simple rule to both keep my history clean and retain commit parentage.
When I'm merging a new branch for the first time, I rebase and do a fast-forward merge. If it happens so that the issue is still not done, I continue working on that branch and all subsequent merges are --no-ff without rebasing. So, all branches maintain continuity through the commit log basically, it remains a single chain of commits without crowding it with petty one-commit "made the copyright font size 0.
Aside from that, I pretty much adhere to Git flow, having master and develop branches, as well as the occasional ones for hotfixes and releases. I agree with rconklin , rebase is a useless lie; on top of which it can introduce dumb merge conflicts in some cases. If you want to look at a pretty straight line of commits, just do git log --no-merges. The compare and pull request pages use different methods to calculate the diff for changed files:.
All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request. Or, learn how to contribute. GitHub Docs. Commit changes to your project. Collaborate with pull requests. About pull requests. In this article About pull requests. Differences between commits on compare and pull request pages. About pull requests Note: When working with pull requests, keep the following in mind: If you're working in the shared repository model , we recommend that you use a topic branch for your pull request.
While you can send pull requests from any branch or commit, with a topic branch you can push follow-up commits if you need to update your proposed changes. It will look something like this:. You must resolve these conflicts future link. Literally, at each locus of conflict, pick one version or the other upstream or local or create a hybrid yourself. Mark the affected file foo. R as resolved via git add and make an explicit git commit to finalize this merge. It avoids a merge commit, so the history is less cluttered and is linear.
It can make merge conflicts more onerous to resolve, which is why I still recommend git pull as the entry-level solution. Notice that you were NOT kicked into an editor to fiddle with the commit message for the merge commit, because there is no merge commit! This is the beauty of rebasing. It is as if we pulled the upstream work in commit C , then did the local work embodied in commit D. We have no cluttery merge commits and a linear history. The bad news: As with plain vanilla git pull , it is still possible to get merge conflicts with git pull --rebase.
If you have multiple local commits, you can even find yourself resolving conflicts over and over, as these commits are sequentially replayed. Hence this is a better fit for more experienced Git users and in situations where conflicts are unlikely those tend to be correlated, actually. At this point, if you try to do git pull --rebase and get bogged down in merge conflicts, I recommend git rebase --abort to back out.
For now, just pursue a more straightforward strategy. This can be done using git reset. First, make sure you have the most recent copy of that remote tracking branch by fetching. Then, use git reset --hard to move the HEAD pointer and the current branch pointer to the most recent commit as it exists on that remote tracking branch. If there have been new commits on both your local branch and the remote branch, a merge commit will be created when you git pull. This recursive merge is the default merge style when there are two splits in history being brought together.
But, you may want history on a branch to be only one line. You can update your local working branch with commits from the remote, but rewrite history so any local commits occur after all new commits coming from the remote, avoiding a merge commit.
This is done with git pull --rebase. Contribute to this article on GitHub. Review code, manage projects, and build software alongside 40 million developers. Skip to content. Git Guides. Sign up for GitHub. Git Pull git pull updates your current local working branch, and all of the remote tracking branches. What Does git pull Do?
0コメント