covered Git basics. This session will include Working with logs Stash Versioning basics Git workflows Gitflow Workflow in details Kapil Sharma PHP REBOOT 4
to check history. Git log provide lot of options to format log as per our requirements Also provide many options to filter logs. Lets check the basics Kapil Sharma PHP REBOOT 5
Most basic logging option It will display ‘commit hash’, ‘Author name and email’, ‘Date of commit’ and ‘message’. With lot of commits in the project, might be difficult to read without formatting and filtering.
commit 779a83dd085a3eabd3a90524234f841a993700cd Author: unknown <[email protected]> Date: Wed Nov 19 21:03:18 2014 +0530 Issue20 diff --git a/public_html/meetup.php b/public_html/meetup.php index 6f3cd45..87efacc 100644 --- a/public_html/meetup.php +++ b/public_html/meetup.php @@ -16,7 +16,7 @@ require_once($config['include_path'] . 'header.php'); <p> - Saturday, December 13th, 2014 <br/> + Saturday, December 20th, 2014 <br/> 11:00 a.m. to 2:00 p.m. </p> <p> @@ -41,7 +41,7 @@ require_once($config['include_path'] . 'header.php'); </p> <p> <strong>Workshop: (13:15-14:00)</strong><br/><br/> - Once of the common feedback we found during meetups is, + Once of the common feedback we found during meetups is, <strong>Prerequisite for Git Workshop:</strong><br/> (END)
Like git log –p but show summary of changes with number of added/deleted lines. Example $ git log –stat -1 commit e08b0fa68fb7e11de15572785d0d342df770db07 Author: kapilsharma <[email protected]> Date: Sat Dec 13 13:42:53 2014 +0530 readme.md finished readme.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
REBOOT 14 Show commit hash and commit message in one line. Useful to compare many commits. Example: $ git log --pretty=oneline e08b0fa68fb7e11de15572785d0d342df770db07 readme.md finished 95c22815ccf7f0d4fc0c29df700c5ece37c8afbb added config part 79956e0332fbe6ab3a9ca130b1b805fca5f987ea Commit early ba9add8e27720d8627a68cc14957332988dfc990 First commit
19 Show ASCII graph of Branches for quick visualization. Example $ git log --pretty=format:"%h - %s" --graph * 7ee5e22 - Magazie page + few minor changes in menu and footer * d7ac824 - Merge branch 'master' of into f_v2.0 |\ | * 3d23b88 - Update readme.md * | 3c05afe - home page finished * | 7e9bcdd - Changed footer and slide show * | afc3f8d - Deleted old template files |/ * 3947488 - Analytics * f80400c - addming folder as server is not supporting www
Kapil Sharma PHP REBOOT 20 Logs within period Logs of specific file/folder git log <file-or-folder-name-with-path> There are many other log option and filters which can be handy in certain conditions. It is not possible/practical to discuss all of them here. Please visit official Git documentation to go through all possible options.
cant be committed but you have to switch the branch. Stash is very helpful tool in such conditions. Stash take a snapshot of your uncommitted work (except untracked files) and save them. That saved stage can be retrieved later. Kapil Sharma PHP REBOOT 21
stached code. Example Kapil Sharma PHP REBOOT 23 git stash list git stash list stash@{0}: WIP on master: 049d078 added the index file stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{2}: WIP on master: 21d80a5 added number to log
of assigning versions to our project/product. We will need it to understand gitflow workflow example. A good way of versioning is ‘Semantic Versioning Specification’, authored by Tom Preston-Werner, Cofounder of GitHub. These specification can be found at http://semver.org Kapil Sharma PHP REBOOT 26
integers. MAJOR version when you make incompatible API changes. MINOR version when you add functionality in a backwards-compatible manner. PATCH version when you make backwards-compatible bug fixes. Kapil Sharma PHP REBOOT 27 MAJOR.MINOR.PATCH Please visit semver.org for full specifications.
There are many possible workflows, to suite style of your team. If a wrong workflow selected, you will not be taking full benefit of power provided by Git. We will be taking example of ‘Gitflow workflow’, which is standard among many organization. It is not too complicated for small/single person team or powerful enough for large teams. Kapil Sharma PHP REBOOT 28
Driessen on blog post nvie.com/posts/a-successful-git-branching-model The Gitflow Workflow defines a strict branching model designed around the project release and good for big teams working on large projects. However it can be easily used for small teams. It do not add any new command but just tell how git branches should be used. Kapil Sharma PHP REBOOT 29
is pushed to master branch for production release. git push origin release Git checkout master git push origin master On Server git pull origin master Kapil Sharma PHP REBOOT 40
through release branch) 19 & 20 Also merge hotfix to develop and feature branch 21 Feature_m2 development still not impacted. Kapil Sharma PHP REBOOT 45