If I have a repo in gitlab. Is it possible to detect the operating system a commit was sent from?
Or is this impossible?
Unusual request I know! I've googled a lot but finding it difficult to find the right search query. Maybe there is a Git spec that would help.
Edit: This is an employer requirement to use a given linux computer that is awful and terribly slow. I'm hoping I can use my personal windows machine without being traced.
CodePudding user response:
Git doesn't store the OS or version information in the commit, so in the general case, there's no way to know.
However, you may be able to use some heuristics to guess the OS. For example, if the repository uses a working-tree-encoding=UTF-16LE-BOM
in .gitattributes
, it's likely that the file in question was committed on Windows. Similarly, if there's a non-UTF-8 commit encoding (which tends to be extremely rare these days), then that may also provide some indication, since some encodings are more common on some platforms than others. You may also be able to guess based on the author or committer information, knowing, for example, that I always commit from a Linux (or, rarely, macOS) machine.
However, for most projects, there isn't any way to know other than by guessing based on other metadata, and other than the author or committer information, most repositories don't have such relevant metadata.
Similarly, GitHub and GitLab have no way of knowing this, either, since it isn't possible to know for certain what OS a remote system is using, although in some cases they may log or provide the user-agent and/or SSH banner information used to push the commit, which can differ based on system. However, that doesn't tell you what system the commit was created on, only what system pushed it, and they don't have to be the same.
CodePudding user response:
No and why would you even care?
I may be writing code on my linux box that is for a Windows application but pushed that code to the repository from my old Dos laptop.