You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.6 KiB
122 lines
4.6 KiB
11 months ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||
|
|
||
|
<!-- Enable responsiveness on mobile devices-->
|
||
|
<!-- viewport-fit=cover is to support iPhone X rounded corners and notch in landscape-->
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, viewport-fit=cover">
|
||
|
|
||
|
<title>Julio Biason .Me 4.3</title>
|
||
|
|
||
|
<!-- CSS -->
|
||
|
<link rel="stylesheet" href="https://blog.juliobiason.me/print.css" media="print">
|
||
|
<link rel="stylesheet" href="https://blog.juliobiason.me/poole.css">
|
||
|
<link rel="stylesheet" href="https://blog.juliobiason.me/hyde.css">
|
||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body class=" ">
|
||
|
|
||
|
<div class="sidebar">
|
||
|
<div class="container sidebar-sticky">
|
||
|
<div class="sidebar-about">
|
||
|
|
||
|
<a href="https://blog.juliobiason.me"><h1>Julio Biason .Me 4.3</h1></a>
|
||
|
|
||
|
<p class="lead">Old school dev living in a 2.0 dev world</p>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<ul class="sidebar-nav">
|
||
|
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/">English</a></li>
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/pt">Português</a></li>
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/tags">Tags (EN)</a></li>
|
||
|
|
||
|
<li class="sidebar-nav-item"><a href="/pt/tags">Tags (PT)</a></li>
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div class="content container">
|
||
|
|
||
|
<div class="post">
|
||
|
<h1 class="post-title">Things I Learnt The Hard Way - One Commit Per Change</h1>
|
||
|
<span class="post-date">
|
||
|
2019-07-09
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/books/">#books</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/things-i-learnt/">#things i learnt</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/source-control/">#source control</a>
|
||
|
|
||
|
<a href="https://blog.juliobiason.me/tags/commits/">#commits</a>
|
||
|
|
||
|
</span>
|
||
|
<p>When working with source control tools, keep one change per commit. Avoid
|
||
|
bundling more than one change in a single commit just to "save time".</p>
|
||
|
<span id="continue-reading"></span>
|
||
|
<p>I've seen my fair share of commits with messages like "Fix issues #1, #2
|
||
|
and #3". This is not something you should do. One commit for fixing issue #1,
|
||
|
another for #2 and yet another for #3.</p>
|
||
|
<p>Just note that I said "one commit per change", not "one commit per file".
|
||
|
Sometimes, to make a single change, you may need to change more than one file
|
||
|
-- it may point that you have a coupling problem, but that's a different
|
||
|
issue. You could, for example, make one commit which adds a new field in model
|
||
|
without adding a change in the controller to load this field; after all, the
|
||
|
controller won't (or, at least, shouldn't) break due the added field, and the
|
||
|
model won't break (or, at least, shouldn't) break because the controller is
|
||
|
not touching the field<sup class="footnote-reference"><a href="#1">1</a></sup>.</p>
|
||
|
<p>When making a commit, think this: "In case something goes wrong, can I undo
|
||
|
this commit without breaking other stuff?" Commit history is stacked, so
|
||
|
obviously you'd have to undo the commits on top of that one. And that's
|
||
|
alright.</p>
|
||
|
<p><strong>BONUS TIP</strong>! If you're using <code>git</code>, you can use <code>git add -p</code> in case you
|
||
|
"overchange". It will allow you to pick parts of a file, instead of adding all
|
||
|
the changes in the file before committing.</p>
|
||
|
<div class="footnote-definition" id="1"><sup class="footnote-definition-label">1</sup>
|
||
|
<p>Ok, it <em>may</em> have some issues if the field can't be null, but you get
|
||
|
what I meant, right?</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
|
||
|
<div style="float:left">
|
||
|
<< <a href="/books/things-i-learnt/always-vcs">Always Use A Version Control System</a>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div style="float:right">
|
||
|
<a href="/books/things-i-learnr/gerrit">Gerrit Is A Mistake</a> >>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
|
||
|
</html>
|