mirror of
https://github.com/linkedin/school-of-sre
synced 2026-01-08 01:28:03 +00:00
341 lines
13 KiB
HTML
341 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="../../img/favicon.ico">
|
|
<title>Github and Hooks - SchoolOfSRE</title>
|
|
<link href="../../css/bootstrap-custom.min.css" rel="stylesheet">
|
|
<link href="../../css/font-awesome.min.css" rel="stylesheet">
|
|
<link href="../../css/base.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
|
|
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
|
<!--[if lt IE 9]>
|
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
|
<![endif]-->
|
|
|
|
<script src="../../js/jquery-1.10.2.min.js" defer></script>
|
|
<script src="../../js/bootstrap-3.0.3.min.js" defer></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
|
<div class="container">
|
|
|
|
<!-- Collapsed navigation -->
|
|
<div class="navbar-header">
|
|
<!-- Expander button -->
|
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="../..">SchoolOfSRE</a>
|
|
</div>
|
|
|
|
<!-- Expanded navigation -->
|
|
<div class="navbar-collapse collapse">
|
|
<!-- Main navigation -->
|
|
<ul class="nav navbar-nav">
|
|
<li >
|
|
<a href="../..">Home</a>
|
|
</li>
|
|
<li class="dropdown active">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Fundamentals Series <b class="caret"></b></a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li class="dropdown-submenu">
|
|
<a href="#">Git</a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li >
|
|
<a href="../git-basics/">Git Basics</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../branches/">Working With Branches</a>
|
|
</li>
|
|
|
|
<li class="active">
|
|
<a href="./">Github and Hooks</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown-submenu">
|
|
<a href="#">Linux Networking</a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li >
|
|
<a href="../../linux_networking/intro/">Introduction</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../linux_networking/dns/">DNS</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../linux_networking/udp/">UDP</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../linux_networking/http/">HTTP</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../linux_networking/tcp/">TCP</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../linux_networking/ipr/">Routing and Conclusion</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Python and Web <b class="caret"></b></a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li >
|
|
<a href="../../python_web/intro/">Introduction</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../python_web/python-concepts/">Some Python Concepts</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../python_web/python-web-flask/">Python, Web and Flask</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../python_web/url-shorten-app/">The URL Shortening App</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../python_web/sre-conclusion/">SRE Aspects of The App and Conclusion</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Systems Design <b class="caret"></b></a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li >
|
|
<a href="../../systems_design/intro/">Introduction</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../systems_design/scalability/">Scalability</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../systems_design/availability/">Availability</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../systems_design/fault-tolerance/">Fault Tolerance</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../systems_design/conclusion/">Conclusion</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Data <b class="caret"></b></a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li class="dropdown-submenu">
|
|
<a href="#">Big Data</a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li >
|
|
<a href="../../big_data/intro/">Introduction</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../big_data/overview/">Overview of Big Data</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../big_data/usage/">Usage of Big Data techniques</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../big_data/evolution/">Evolution of Hadoop</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../big_data/architecture/">Architecture of Hadoop</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../big_data/tasks/">Tasks and conclusion</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Security <b class="caret"></b></a>
|
|
<ul class="dropdown-menu">
|
|
|
|
<li >
|
|
<a href="../../security/intro/">Introduction</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../security/fundamentals/">Fundamentals of Security</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../security/network_security/">Network Security</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../security/threats_attacks_defences/">Threat, Attacks & Defences</a>
|
|
</li>
|
|
|
|
<li >
|
|
<a href="../../security/writing_secure_code/">Writing Secure code</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<ul class="nav navbar-nav navbar-right">
|
|
<li >
|
|
<a rel="next" href="../branches/">
|
|
<i class="fa fa-arrow-left"></i> Previous
|
|
</a>
|
|
</li>
|
|
<li >
|
|
<a rel="prev" href="../../linux_networking/intro/">
|
|
Next <i class="fa fa-arrow-right"></i>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
|
|
<ul class="nav bs-sidenav">
|
|
<li class="main active"><a href="#git-with-github">Git with Github</a></li>
|
|
<li class="main "><a href="#hooks">Hooks</a></li>
|
|
<li class="main "><a href="#what-next-from-here">What next from here?</a></li>
|
|
</ul>
|
|
</div></div>
|
|
<div class="col-md-9" role="main">
|
|
|
|
<h2 id="git-with-github">Git with Github</h2>
|
|
<p>Till now all the operations we did were in our local repo while git also helps us in a collaborative environment. GitHub is one place on the internet where you can centrally host your git repos and collaborate with other developers.</p>
|
|
<p>Most of the workflow will remain the same as we discussed, with addition of couple of things:</p>
|
|
<ol>
|
|
<li>Pull: to pull latest changes from github (the central) repo</li>
|
|
<li>Push: to push your changes to github repo so that it's available to all people</li>
|
|
</ol>
|
|
<p>GitHub has written nice guides and tutorials about this and you can refer them here:</p>
|
|
<ul>
|
|
<li><a href="https://guides.github.com/activities/hello-world/">GitHub Hello World</a></li>
|
|
<li><a href="https://guides.github.com/introduction/git-handbook/">Git Handbook</a></li>
|
|
</ul>
|
|
<h2 id="hooks">Hooks</h2>
|
|
<p>Git has another nice feature called hooks. Hooks are basically scripts which will be called when a certain event happens. Here is where hooks are located:</p>
|
|
<pre><code class="bash">spatel1-mn1:school-of-sre spatel1$ ls .git/hooks/
|
|
applypatch-msg.sample fsmonitor-watchman.sample pre-applypatch.sample pre-push.sample pre-receive.sample update.sample
|
|
commit-msg.sample post-update.sample pre-commit.sample pre-rebase.sample prepare-commit-msg.sample
|
|
</code></pre>
|
|
|
|
<p>Names are self explanatory. These hooks are useful when you want to do certain things when a certain event happens. Ie: if you want to run tests before pushing code, you would want to setup <code>pre-push</code> hooks. Let's try to create a pre commit hook.</p>
|
|
<pre><code class="bash">spatel1-mn1:school-of-sre spatel1$ echo "echo this is from pre commit hook" > .git/hooks/pre-commit
|
|
spatel1-mn1:school-of-sre spatel1$ chmod +x .git/hooks/pre-commit
|
|
</code></pre>
|
|
|
|
<p>We basically create a file called <code>pre-commit</code> in hooks folder and make it executable. Now if we make a commit, we should see the message getting printed.</p>
|
|
<pre><code class="bash">spatel1-mn1:school-of-sre spatel1$ echo "sample file" > sample.txt
|
|
spatel1-mn1:school-of-sre spatel1$ git add sample.txt
|
|
spatel1-mn1:school-of-sre spatel1$ git commit -m "adding sample file"
|
|
this is from pre commit hook # <===== THE MESSAGE FROM HOOK EXECUTION
|
|
[master 9894e05] adding sample file
|
|
1 file changed, 1 insertion(+)
|
|
create mode 100644 sample.txt
|
|
</code></pre>
|
|
|
|
<h2 id="what-next-from-here">What next from here?</h2>
|
|
<p>There are a lot of git commands and features which we have not explored here. But with the base built-up, be sure to explore concepts like</p>
|
|
<ul>
|
|
<li>Cherrypick</li>
|
|
<li>Squash</li>
|
|
<li>Amend</li>
|
|
<li>Stash</li>
|
|
<li>Reset</li>
|
|
</ul></div>
|
|
</div>
|
|
|
|
<footer class="col-md-12">
|
|
<hr>
|
|
<p>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</p>
|
|
</footer>
|
|
<script>
|
|
var base_url = "../..",
|
|
shortcuts = {"search": 83, "next": 78, "help": 191, "previous": 80};
|
|
</script>
|
|
<script src="../../js/base.js" defer></script>
|
|
|
|
<div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="Keyboard Shortcuts Modal" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
|
<h4 class="modal-title" id="exampleModalLabel">Keyboard Shortcuts</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 20%;">Keys</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="help shortcut"><kbd>?</kbd></td>
|
|
<td>Open this help</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="next shortcut"><kbd>n</kbd></td>
|
|
<td>Next page</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="prev shortcut"><kbd>p</kbd></td>
|
|
<td>Previous page</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="search shortcut"><kbd>s</kbd></td>
|
|
<td>Search</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="modal-footer">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|