![]() This would make the development history harder to review, not easier.īeware: git rebase might not do what you expect it to do, so review the results before pushing. Without -p, every commit on the feature branch would be duplicated on master as part of the linearization done by git rebase. This is important if, for example, you merged a feature branch into master. This prevents Git from linearizing the commits being rebased. The -p option tells Git to preserve merges. This improves the linearity of the development history, making it easier to review. Git rebase -p effectively moves the commits you've made but haven't yet pushed on top of the upstream branch, which eliminates the need to create the silly merge commits you're trying to avoid. Git merge -ff-only tells Git to merge the upstream branch (the argument) into your local branch but only if your local branch can be "fast forwarded" to the upstream branch (in other words, if it hasn't diverged). Thus, if the foo branch is deleted in the origin repository, git remote update -p will automatically delete your origin/foo ref. The -p argument prunes deleted upstream branches. It does NOT touch your working directory, index, or local branches. Git rebase -p remote update -p downloads all of the commits in the remote repositories and updates the remote tracking branches (e.g., origin/master). Git merge -ff-only if the above fails with a complaint that the local branch has Instead, I encourage you to follow this usage pattern: # download the latest commits You could use git pull -rebase to prevent this from happening in the future, but rebasing has its perils, and I recommend avoiding pull altogether. How to avoid these merge commits in the future If you make a local commit and then run git pull after someone else pushes a commit up to the repository, Git downloads the other developer's commit and then merges it into your local branch. Git pull is probably creating the commit.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |