I would like to see the name of files modified in my git history, but not including one commit.
When I use the command: git log --oneline
, git returns these commits:
The problem is the commit 0810c44
. This commit because it is a sync commit and it contains a lot of files that were update, but they aren't needed for my current task (It contains a lot of files to synchronize with my local repo).
I would like to see all name of file changed from the current HEAD to a previous commit (example, 824be3b
), but in a way that the commit 0810c44
is omitted, how can I do this?
Git returns as text:
git log --oneline
9dfe1b9 (HEAD -> tmp_merge_branch) merge
0810c44 retrieved
ff16e9a (1362-bolecode) commerce user permission
3de9164 update flow filter
ec04c9e xml
8851063 add untracked permissions, profiles, etc...
252b039 object
b5db337 add new flows
d9cb7de add B2BCommerceUser Permission Set
f9dc6d2 add diferences from Merge
c0d5f11 remove files
824be3b check before deploy
3212074 restante
69ef93e retrieved
PS C:\> git log --name-only
commit 9dfe1b9a919c2153f1af56cd21f13d750588b4f6 (HEAD -> tmp_merge_branch)
Author: Me
Date: Mon Nov 14 16:12:44 2022 -0300
merge
mergeFolder/classes/BoletoItauController.cls
mergeFolder/classes/RegisterBolecodeTest.cls
mergeFolder/flows/Boleto_Bolecode_Integration.flow
mergeFolder/flows/Boleto_Bolecode_Integration_On_Create.flow
mergeFolder/permissionsets/B2BCommerceUser.permissionset
commit 0810c44fc622d476d54d713b23c993891d7219df
Author: Me
Date: Mon Nov 14 14:14:42 2022 -0300
retrieved
mergeFolder/classes/BolecodeService.cls
mergeFolder/classes/BolecodeService.cls-meta.xml
mergeFolder/classes/BolecodeServiceTest.cls
mergeFolder/classes/BolecodeServiceTest.cls-meta.xml
mergeFolder/classes/BolecodeStructure.cls
mergeFolder/classes/BolecodeStructure.cls-meta.xml
mergeFolder/classes/BoletoApiService.cls
mergeFolder/classes/BoletoApiService.cls-meta.xml
mergeFolder/classes/BoletoApiServiceMock.cls
mergeFolder/classes/BoletoApiServiceMock.cls-meta.xml
mergeFolder/classes/BoletoApiServiceTest.cls
mergeFolder/classes/BoletoApiServiceTest.cls-meta.xml
mergeFolder/classes/BoletoBo.cls
mergeFolder/classes/BoletoBo.cls-meta.xml
mergeFolder/classes/BoletoDAO.cls
mergeFolder/classes/BoletoDAO.cls-meta.xml
mergeFolder/classes/BoletoItauController.cls
mergeFolder/classes/BoletoItauController.cls-meta.xml
mergeFolder/classes/BoletoService.cls
mergeFolder/classes/BoletoService.cls-meta.xml
<log with 74 files in total>
commit 9dfe1b9a919c2153f1af56cd21f13d750588b4f6 (HEAD -> tmp_merge_branch)
Author: Me
Date: Mon Nov 14 16:12:44 2022 -0300
merge
mergeFolder/classes/BoletoItauController.cls
mergeFolder/classes/RegisterBolecodeTest.cls
mergeFolder/flows/Boleto_Bolecode_Integration.flow
mergeFolder/flows/Boleto_Bolecode_Integration_On_Create.flow
mergeFolder/permissionsets/B2BCommerceUser.permissionset
CodePudding user response:
I don't have a simple command for you but here are a couple of "workaround" solutions that should achieve your end goal.
If there aren't that many commits you want, start with a branch that has none of these commits, from there, you could create a new temp branch, and git cherry-pick only the commits you want to see results for, and then run your command for the temp branch.
If there are lots of commits that you want to see results for, and only one that you want to omit, then you could try a similar strategy to above, but create a branch from your current branch with all of the commits on it, and then revert your current commit. Again, this leaves you with a branch of the desired commits - run your command to get the list of files you need, and jump back over to your actual branch.
CodePudding user response:
I don't think there is a way to exclude a single commit from showing up in history using git log, however to list all files changed across several commits you can use git diff
, and together with reverting the specific commit you should be able to achieve the desired result. Consider the following git history (git log -p
):
commit d9d6084ebc16effd52327fd67b82860d5b9510a3 (main)
Author: micromoses <micromoses>
Date: Wed Nov 16 21:51:24 2022 0200
Added e.txt
diff --git a/e.txt b/e.txt
new file mode 100644
index 0000000..d905d9d
--- /dev/null
b/e.txt
@@ -0,0 1 @@
e
commit 6a3c93aa8746e9d81a7dceefd8f4210bacf1103b
Author: micromoses <micromoses>
Date: Wed Nov 16 21:52:43 2022 0200
Modified d.txt
diff --git a/d.txt b/d.txt
index 4bcfe98..32a8474 100644
--- a/d.txt
b/d.txt
@@ -1 1,2 @@
d
modified d
commit 90b7155196a272ca19417b451320a9c66f619f35
Author: micromoses <micromoses>
Date: Wed Nov 16 21:51:24 2022 0200
Added d.txt
diff --git a/d.txt b/d.txt
new file mode 100644
index 0000000..4bcfe98
--- /dev/null
b/d.txt
@@ -0,0 1 @@
d
commit 8cee8643364631e91f91d36f23d5bf0c3c89354d
Author: micromoses <micromoses>
Date: Wed Nov 16 21:51:24 2022 0200
Added c.txt
diff --git a/c.txt b/c.txt
new file mode 100644
index 0000000..f2ad6c7
--- /dev/null
b/c.txt
@@ -0,0 1 @@
c
commit 1ff08cfde30e9b3ee358ffe1e8ce83d6f08c293b
Author: micromoses <micromoses>
Date: Wed Nov 16 21:51:24 2022 0200
Added b.txt
diff --git a/b.txt b/b.txt
new file mode 100644
index 0000000..6178079
--- /dev/null
b/b.txt
@@ -0,0 1 @@
b
commit 36d3284a11b001ecd02d1ab817546bc51ea16cb5
Author: micromoses <micromoses>
Date: Wed Nov 16 21:51:24 2022 0200
Added a.txt
diff --git a/a.txt b/a.txt
new file mode 100644
index 0000000..7898192
--- /dev/null
b/a.txt
@@ -0,0 1 @@
a
commit 76da7ed781432d4d7348359665a50baa2df7ac39
Author: micromoses <micromoses>
Date: Wed Nov 16 21:49:57 2022 0200
Initial commit
Let's say we want to exclude 2 commits, 6a3c93a
and 8cee864
. We can create a new branch, revert these 2 commits, and run git diff:
$ git checkout -b temp_revert
$ git revert 6a3c93aa8746e9d81a7dceefd8f4210bacf1103b
$ git revert 8cee8643364631e91f91d36f23d5bf0c3c89354d
$ git diff --name-only 76da7ed781432d4d7348359665a50baa2df7ac39
a.txt
b.txt
d.txt
e.txt
Notice that c.txt
is removed from the list, but d.txt
still shows up - because it was modified in commit 90b7155
, which we wanted to include.
While reverting a historic commit may result in conflicts, for the purpose of listing modified files this is not a problem, as it only indicates that the files were modified at a later stage. I wouldn't bother resolving them, I would actually commit the revert without any editing. The end result would still show these files as modified, which is the desired result.