![]() ![]() When we perform the merge operation a new file (sample.php) from the target (dev) branch is added to the current (master) branch. So, in the above merge example the target branch is the dev branch and the current branch is the master branch. But the target branch remains unaffected. So, new files get added, exisiting files, if modified, gets updated. When we merge the target branch into the current branch, the current branch gets updated to reflect the changes. Note! The merge was a Fast-Forward merge (more on that later in this tutorial). You can see that sample.php file got added to the master branch working directory after the merge from the dev branch. rw-r-r- 1 yusufshakeel staff 0 Oct 8 16:44 sample.php ĭrwxr-xr-x 15 yusufshakeel staff 480 Oct 8 16:44. rw-r-r- 1 yusufshakeel staff 0 Sep 18 21:10 index.phpĭrwxr-xr-x 3 yusufshakeel staff 96 Sep 12 19:46 jsġ file changed, 0 insertions(+), 0 deletions(-)ĭrwxr-xr-x 6 yusufshakeel staff 192 Oct 8 16:44. ĭrwxr-xr-x 15 yusufshakeel staff 480 Oct 8 16:43. ĭrwxrwxrwx 30 yusufshakeel staff 960 Oct 2 22:48. So, if we are on master branch (i.e., current branch) and we run the git merge dev command then we will merge the dev branch (i.e., target branch) into the master branch.ĭrwxr-xr-x 5 yusufshakeel staff 160 Oct 5 19:47. ![]() To merge a given branch into the currect branch we use the git merge command. #MERGE UPDATED BRANCH TO MASTER GIT HOW TO#So, we have already learned in the previous tutorials how to create branches and how to checkout branches. That's why from now on, I'm going to be doing lots of merging but without fast forwarding.In this tutorial we will learn to merge branches in Git. Without it, we're lost because we can't tell the forest from the trees. If there's anything you guys know about me, it's that context is king. #MERGE UPDATED BRANCH TO MASTER GIT CODE#Of course the end result in terms of the source code is the same, but we know how we got there. But by appending "-no-ff" onto the merge command, you'll retain the context and the merge is maintained. If you merge and you do so by fast forwarding, that context has been lost. The whole idea is that each time you do something, you to keep its identity and know that it came as a result of a particular bug. The "no-ff" stands for "no fast forward". (There's another great article on why rebase is bad.) The thing about rebase and merge is that they creates a single "branch" that is long and all of the work that you performed for a particular work item or bug or whatever gets lost in the single master branch. ![]() Then, when I'd go to push, I'd first pull in changes, rebase, and push. Instead, I'd often just do my work on my own local copy and use master. One of the things about Git that I never worried about too much was leveraging branches for various work items. If you're not using Git, you'd better be using some form of distributed version control. It's a great article in its own right and deserves your attention if you're using Git. Over a year ago I bumped into a great article about A Successful Git Branching Model. I've been using Git now for several years. Subscribe My New Best Friend: git merge -no-ff ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |