![]() & git commit -m 'Add quickfix code.' ”quickfix” history after making a single commit * 043925a | Add quickfix code. (HEAD -> master) * 5e69ac9 | 2 commit: hello.sh code file added. What is a merge and its typesMerging together the work of different branches.Git merge branch to another branch.a) Fast-forward merge”feature” or child branch progresses while the “master” or parent branch does not.‘feature’ branch code is merged into ‘master’ branch, that progresses the HEAD of master on to the tip of ‘feature’ branch commit.b) 3-way or recursive mergeThe nomenclature comes from the fact that Git uses three commits to generate the merge commit: the two branch tips and their common ancestor.Diagram: ‘feature’ branch develops after branching out from ‘master’ ‘master’ branch progresses while ‘feature’ branch is under developmentDiagram: ‘feature’ branch merged into ‘master’ As in the case of a fast-forward merge, the tip of both the branches: ‘feature’ and ‘master’ both progresses and points to the same latest commit.c) 3-way merge vs fast-forward git merge demoDemo: Fast-forward mergeStep 1: master history before mergegit hist * 5e69ac9 | 2 commit: hello.sh code file added. (HEAD -> master, quick_fix) * 4871096 | 1 commit: Initial Project structure and Readme file added. Step 2: Create a ‘quickfix’ branch git checkout -b quickfix * 5e69ac9 | 2 commit: hello.sh code file added. (HEAD -> master, quick_fix) * 4871096 | 1 commit: Initial Project structure and Readme file added. Step 3: make a single commit in “quickfix” branchecho "quickfix added" > quickfix.file git add. Switch between branchesSwitch/jump to the new branchgit checkout newBranchSwitch back to master branchgit checkout master4. ![]() Create a branchProject: learn_branching-git list branches using the command: git $git branch iss53 * master new-feature newBranchCreate a new branch from the latest commit-create branch gitgit branch newBranchCreate a branch from an old commitgit branch firstBranch commitIDCreate a branch and jump onto itgit checkout -b quickfix3. ![]() | |/ |/| | | * 43d4441 (tag: new, myProj/master) Update README to version 3.2 | | * 0f491ba (myProj/issue) Merge branch 'master' of | | |\ Set an alias for this command in the config filegit config -global alias.showbranches 'log -graph -oneline -all -decorate' git showbranches2. | | * 7287290 (preprod, development) Adding main function | |/ |/| | | * 820c0e8 (origin/iss53) end of bug fix.Tested. * | c5487f5 adding quickfix |/ | * dff8df9 (HEAD -> master, origin/master) 2 commit: hello.sh code file added. * 4871096 1 commit: Initial Project structure and Readme file added.#To visualize the graphical logs for all the branchesgit log -graph -oneline -all -decorate-decorate: adds labels to the commits (HEAD, tags, remote branches and local branches)* 277c573 (quickfix, iss53) Merged branch iss53 into quickfix |\ | * 13fbd09 iss53 bug fixed. What is a branch and visualize branchesIndependent line of development or parallel development of code along with the main code.Branches are used to develop a new feature or to fix a bug in the code.In other words:Branch is a reference to a commit.cd learn_branching#To visualize the graphical logs for current branchgit log -oneline -graph * dff8df9 (HEAD -> master, origin/master) 2 commit: hello.sh code file added.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |