LoginSignup
1

More than 5 years have passed since last update.

最高のGit運用をするための9の方法

Last updated at Posted at 2017-12-16
1 / 24

この資料は12/16(土)に行われた、だいたい新卒エンジニア向け技術交流会 vol.13の発表資料です。
発表時から一部変更を加えています。


今日は最高のGit運用の話をします


これをすれば同僚から一目置かれる存在に


自己紹介なんていらない


早速行きましょう


1. メインブランチにコミット


2. 改行コードを混ぜ込む


CRLFとLFを混ぜ込んでみよう!
そうするとめっちゃ差分出るしコンフリクトするので治し甲斐があるなあってなるぞ!

Git改行コード変更.png

-namespace SampleMvc.Models
-{
-    public class Article
-    {
-        public int Id { get; set; }
-
-        public string Title { get; set; }
-
-        public string Content { get; set; }
-    }
-}
+namespace SampleMvc.Models^M
+{^M
+    public class Article^M
+    {^M
+        public int Id { get; set; }^M
+^M
+        public string Title { get; set; }^M
+^M
+        public string Content { get; set; }^M
+    }^M
+}^M

Windows環境だとcore.autocrlfとか有効にすれば全部LFになるけどそんなものは無視だ!


3. 文字コードを変更する


 namespace SampleMvc.Models
 {
     /// <summary>
-    /// 記事
+    /// <8B>L<8E><96>
     /// </summary>
     public class Article
     {

同僚は頭の中で文字コードを変換できるように成長するだろう。


4. コンフリクトしたらプッシュ


diff --git a/Article.cs b/Article.cs
index bd41686..93834b7 100644
--- a/Article.cs
+++ b/Article.cs
@@ -11,6 +11,10 @@ namespace SampleMvc.Models

         public string Content { get; set; }

+<<<<<<< HEAD
         public IEnumerable<string> RelatedLinks { get; set; }
+=======
+        public DateTime Created { get; set; }
+>>>>>>> conflict-b
     }
 }

HTMLに入れてあげればエンドユーザーにも届く!


5. マージコミットでファイル削除


diff --git a/Article.cs b/Article.cs
index 8bb591a..af62a0b 100644
--- a/Article.cs
+++ b/Article.cs
@@ -11,6 +11,10 @@ namespace SampleMvc.Models

         public string Content { get; set; }

+<<<<<<< HEAD
         public DateTime Created { get; set; }
+=======
+        public IEnumerable<string> RelatedLinks { get; set; }
+>>>>>>> conflict-a
     }
 }
$ git merge --no-ff conflict-b

$ git status --short
 M Article.cs
?? Tag.cs

$ git status --short
 M Article.cs
?? Tag.cs

$ git checkout -- .

$ git status --short
?? Tag.cs

$ rm Tag.cs

$ git commit

ファイルが消える上にgit log、--付きでも追えなくなるぞ!


6. 全く意味のないコミットメッセージ


7. ビルドできない状態のブランチのマージ


8. ビルドしたものを含める


9. 履歴書き換え、強制プッシュ


そう


これは遠いおとぎの国の現場の話なんだ…


みんな


こうなる前に仕組みと教育で防ごうな!!


Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1