git checkout branch file1 file2 For each file merge the differences in branch s

Git checkout branch file1 file2 for each file merge

This preview shows page 395 - 397 out of 517 pages.

git checkout branch file1 file2... For each file, merge the differences in branch ’s version of that file into the current branch’s version of that file. Figure 10.8: Common Git commands for handling branches and merging. Branch management involves merging; Figure 10.3 tells how to undo merges gone awry. When multiple branches are present, how do you specify which one should receive pushes or pulls? As Figure 10.8 shows, the git push and git pull commands we’ve been using so far are actually abbreviated special cases—these commands handle pushes and pulls using branches as well. Screencast 10.5.1: Using Branches with Git This screencast shows how to create and manage a new branch in Git (for example, to develop a new
Image of page 395
feature), how to merge the branch’s changes back into the trunk from which it was split, and how to undo the merge of the branch if something goes wrong (for example, if it turns out the feature had bugs and needs to be backed out). It also emphasizes an important caveat and shows why you should always commit your changes in the current branch before switching to a different branch. Summary of branching: Branches allow variation in a code base. For example, feature branches support the development of new features without destabilizing working code, and release branches allow fixing bugs in previous releases whose code has diverged from the main line of development. Merging changes from one branch into another (for example, from a feature branch back into the master branch) may result in conflict merges for certain files, so always commit before you merge and before switching to a different branch to work on. With Agile + SaaS, feature branches are usually short-lived and release branches uncommon. ELABORATION: Long-lived Branches and Rebasing While you’re working on a feature branch, its commits will diverge from the trunk; if you work on it for too long, the “big merge” when you’re done may be very painful with many conflicts. The pain can be mitigated by frequent rebasing , an operation in which you incrementally merge some recent changes from another branch, then tell Git to rearrange things to look as if your branch had originated from a later commit. While rebasing is useful for long-lived branches such as release branches or long-lived experimental branches, if you’re breaking down your user stories into manageable sizes (Section 7.2 ) and doing frequent deployments (Section 12.3 ), rebasing should rarely be necessary in agile SaaS development. Self-Check 10.5.1. Describe a scenario in which merges could go in both directions—changes in a feature branch merged back into the master branch, and changes in the master branch merged into a feature branch. (In Git, this is called a crisscross merge .) Diana starts a new branch to work on a feature. Before she completes the feature, an important bug is fixed and the fix is merged into the master branch. Because the bug is in a part of the code that interacts with Diana’s feature, she merges the fix from master into her own feature branch. Finally, when she finishes the feature, her feature branch is merged back into master.
Image of page 396
Image of page 397

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors