I have the following use case:
On my local computer, I had the following structure of files/folders outside of any version control system, including git.
ProjectFolder
---Folder1
----File1.txt
----Folder2
----File2.txt
----100s of other files/folders
In preparation for version control, I first ran git init
in this folder.
This gave me:
ProjectFolder
---.git
---Folder1
----File1.txt
----Folder2
----File2.txt
----100s of other files/folders
I then went to github and created a repository, say:
https://github.com/Tryer/ProjectFolder.git
After this, from the command line on my machine, I issued:
git remote add origin https://github.com/Tryer/ProjectFolder.git
I did not want to add Folder2
and its contents to the commit. I only wanted Folder1
and its contents to be committed.
I, by mistake, did not created a proper .gitignore
file leading to staging of some files from Folder2
when I then issued git add .
I do not now remember exactly whether I issued git rm -f <files from Folder2>
or git rm --cached <files from Folder2>
to unstage the unneeded files from Folder2
. The former would have forced deleted the files from Folder2
from both the staging area as well as my working tree (something I did not intend/want). The latter would have only unstaged the files but left them in my working tree (something that is precisely what I would have wanted.)
The number of files under Folder2
are rather large and a due diligence check on Folder2
's contents manually on my machine seems to reveal nothing amiss in terms of missing files from my working tree.
Yet, just to be absolutely sure, is there a way to list all of the git commands ever issued under a repository from the beginning of time? Note that I am not asking for a history of commands I have issued from the terminal command line. This would be available in a powershell history or bash shell history.
A previous question of exactly this issue is available here. However, the question is about 10 years old and the highest voted answer there suggests to use git reflog
. However, that seems to give history in terms of commits. I am looking more for the exact git commands that I have executed.
CodePudding user response:
No, it's not possible with Git. Git does not keep track of the commands executed in a repository.
Your best bet is your shell's command history.