From patchwork Sun Sep 20 23:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11788159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74EEF112E for ; Sun, 20 Sep 2020 23:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FF9E20809 for ; Sun, 20 Sep 2020 23:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgITXWl (ORCPT ); Sun, 20 Sep 2020 19:22:41 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:35280 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgITXWl (ORCPT ); Sun, 20 Sep 2020 19:22:41 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:b610:a2f0:36c1:12e3]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 528F461FE5; Sun, 20 Sep 2020 23:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1600644160; bh=vMaPNa+Tp7gO4QclUDL1Alyyb2qxOZGMZxuFccZr1y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=u8EtYIpBoNLv2ait7lzknR2mB/hpeiMkWFjQddMHBSRrBlodpSyZRuN2X5l9SNO1s /+K7ankwkRsSBzF6QzoLd0U9+dRrHMvHVLVbsWCj+DKST5XisaUgC7Sk3K/v5J5Y8e 1QN3vTs7QiVXgEyFXrmOT/1xZZu7+2PX1JCHOS/B62alsjV+YRGO0nb9yt2zstPKDm Zero6bIB8tBSck6mPRERmSpWNyJxDMjqPcD2rQkEWaX3pSUxgLc6ZNTueH8nR6StZX Y4NDO9F06pcL5WJTILwJzDIYexZ1ej3wfYYULpzK18Mz6umowriLNhFw/SbgPNrt97 SVMXCFNDJrGpIDUyfMHFPtCIwK+7YJ3c+tTVDaLFdIRUa+t5Ge0okYwnQunhk8A2Vr NzSyQieiiCQOxM+DG6zfT82U/GC093eZI5yS7NzhIa274jBKq1aR23Zcd8pBtkdeVW oGzzQWcjN9HATpEEZ4QP7EcDNhqfWrX/BbF3dDfbAfjy94T69Ci From: "brian m. carlson" To: Cc: =?utf-8?q?Martin_=C3=85gren?= Subject: [PATCH v2 1/3] docs: explain why squash merges are broken with long-running branches Date: Sun, 20 Sep 2020 23:22:29 +0000 Message-Id: <20200920232231.1300394-2-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d In-Reply-To: <20200920232231.1300394-1-sandals@crustytoothpaste.net> References: <20200912204824.2824106-1-sandals@crustytoothpaste.net> <20200920232231.1300394-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In many projects, squash merges are commonly used, primarily to keep a tidy history in the face of developers who do not use logically independent, bisectable commits. As common as this is, this tends to cause significant problems when squash merges are used to merge long-running branches due to the lack of any new merge bases. Even very experienced developers may make this mistake, so let's add a FAQ entry explaining why this is problematic and explaining that regular merge commits should be used to merge two long-running branches. Signed-off-by: brian m. carlson --- Documentation/gitfaq.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt index 9cd7a592ac..51d305d58f 100644 --- a/Documentation/gitfaq.txt +++ b/Documentation/gitfaq.txt @@ -241,6 +241,38 @@ How do I know if I want to do a fetch or a pull?:: ignore the upstream changes. A pull consists of a fetch followed immediately by either a merge or rebase. See linkgit:git-pull[1]. +Merging and Rebasing +-------------------- + +[[long-running-squash-merge]] +What kinds of problems can occur when merging long-lived branches with squash merges?:: + In general, there are a variety of problems that can occur when using squash + merges to merge two branches multiple times. These can include seeing extra + commits in `git log` output, with a GUI, or when using the `...` notation to + express a range, as well as the possibility of needing to re-resolve conflicts + again and again. ++ +When Git does a normal merge between two branches, it considers exactly three +points: the two branches and a third commit, called the _merge base_, which is +usually the common ancestor of the commits. The result of the merge is the sum +of the changes between the merge base and each head. When you merge two +branches with a regular merge commit, this results in a new commit which will +end up as a merge base when they're merged again, because there is now a new +common ancestor. Git doesn't have to consider changes that occurred before the +merge base, so you don't have to re-resolve any conflicts you resolved before. ++ +When you perform a squash merge, a merge commit isn't created; instead, the +changes from one side are applied as a regular commit to the other side. This +means that the merge base for these branches won't have changed, and so when Git +goes to perform its next merge, it considers all of the changes that it +considered the last time plus the new changes. That means any conflicts may +need to be re-resolved. Similarly, anything using the `...` notation in `git +diff`, `git log`, or a GUI will result in showing all of the changes since the +original merge base. ++ +As a consequence, if you want to merge two long-lived branches repeatedly, it's +best to always use a regular merge commit. + Hooks ----- From patchwork Sun Sep 20 23:22:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11788163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E181817E6 for ; Sun, 20 Sep 2020 23:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF92920809 for ; Sun, 20 Sep 2020 23:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgITXXN (ORCPT ); Sun, 20 Sep 2020 19:23:13 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:35296 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgITXXM (ORCPT ); Sun, 20 Sep 2020 19:23:12 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:b610:a2f0:36c1:12e3]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 3053561FE7; Sun, 20 Sep 2020 23:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1600644161; bh=fMsI9ZJTqIFTP4FQY8UNiCvX26TldDkhjOmjXH3iT0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=bY2jQ52JU1rurLIPFRAmp3MWZXFTD8UsilrJi+35w/NXFI58EQ2m1u2hTWoQHMFKy Jp3p4l0/s84TrgbYb9xCZu5k/vWSYOVxiyGFC7uPFwRN5LFa25lQy4DcNm9ihjAyBW l2ou1zFqpLIE6pDQzwNO9eILXxyJH5QMJdmTNxw/RffrX+MV9sDBgVNDhXT2Eirc9G FS1jlxkN6apHMauRQqNy5g7hp4+soaExF7XNTjaYP6cp56fjLzPqcPFhQjkHUl3eTo HCRdQD1B4FTNvtgB87i60IEQ0G+qZnQJU57FZEVDN/scS42R3HXlJxIZHsjKChREnA J0pO4MAB6OVrlWEuEh8BT3c9NMi5Ss4CUec3u5YTLOJBmNShWUeHDK9GUapwkfvlPw JpN9unFIWlyZLS8hAOlRl0b59sAcGoqqWzjDHM0zYzZThq6DER1IbZ7KWthZ7jm0mX Ec7i2YPWngcYN0Wy8m2+asnVrRjyoGhaDJ5Bf6Pc1jBfqfN6ytP From: "brian m. carlson" To: Cc: =?utf-8?q?Martin_=C3=85gren?= Subject: [PATCH v2 3/3] docs: explain how to deal with files that are always modified Date: Sun, 20 Sep 2020 23:22:31 +0000 Message-Id: <20200920232231.1300394-4-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d In-Reply-To: <20200920232231.1300394-1-sandals@crustytoothpaste.net> References: <20200912204824.2824106-1-sandals@crustytoothpaste.net> <20200920232231.1300394-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Users frequently have problems where two filenames differ only in case, causing one of those files to show up consistently as being modified. Let's add a FAQ entry that explains how to deal with that. In addition, let's explain another common case where files are consistently modified, which is when files using a smudge or clean filter have not been run through that filter. Explain the way to fix this as well. Signed-off-by: brian m. carlson --- Documentation/gitfaq.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt index 176b097cf7..afdaeab850 100644 --- a/Documentation/gitfaq.txt +++ b/Documentation/gitfaq.txt @@ -363,6 +363,39 @@ information about how to configure files as text or binary. You can also control this behavior with the `core.whitespace` setting if you don't wish to remove the carriage returns from your line endings. +[[always-modified-files-case]] +Why do I have a file that's always modified?:: + Internally, Git always stores file names as sequences of bytes and doesn't + perform any encoding or case folding. However, Windows and macOS by default + both perform case folding on file names. As a result, it's possible to end up + with multiple files or directories whose names differ only in case. Git can + handle this just fine, but the file system can store only one of these files, + so when Git reads the other file to see its contents, it looks modified. ++ +It's best to remove one of the files such that you only have one file. You can +do this with commands like the following (assuming two files `AFile.txt` and +`afile.txt`) on an otherwise clean working tree: ++ +---- +$ git rm --cached AFile.txt +$ git commit -m 'Remove files conflicting in case' +$ git checkout . +---- ++ +This avoids touching the disk, but removes the additional file. Your project +may prefer to adopt a naming convention, such as all-lowercase names, to avoid +this problem from occurring again; such a convention can be checked using a +`pre-receive` hook or as part of a continuous integration (CI) system. ++ +It is also possible for perpetually modified files to occur on any platform if a +smudge or clean filter is in use on your system but a file was previously +committed without running the smudge or clean filter. To fix this, run the +following on an otherwise clean working tree: ++ +---- +$ git add --renormalize . +---- + [[recommended-storage-settings]] What's the recommended way to store files in Git?:: While Git can store and handle any file of any type, there are some