0

Assuming that you are currently within a Git repository that includes several commits, write the command (or commands) that will display the changes from the commit with the ID of abc123.?

How do you exactly try to provide a certain git commit Id if you are commiting a file after staging. Or how do you retrieve a certain commit with a certain id which does not exist.?

I'm stuck at git commit -m " some text description." and also git reset " "?

how do you approach this?

ashkay63
  • 9
  • 2
  • 5
  • 1
    It's not really clear to me what you are asking here. Each commit has a unique number—a hash ID—and `git log` will show you the hash ID as part of showing you more information about that commit. Each commit also stores a full snapshot of every file. To see what *changed* from one commit to another, Git will compare the previous ("older") snapshot to the subsequent ("newer") snapshot. Both `git log -p` and `git show` do this, with some differences; the biggest difference is that `git show ` shows one commit and stops, while `git log -p` works backwards from the current commit [coninued] – torek Feb 27 '21 at 08:19
  • 1
    ... without stopping until you either get tired of output and quit the `git log -p` command entirely, or it's reached the very first commit or some other limit you choose when you run `git log`. Meanwhile, as to how you retrieve a commit you don't have, well, you can't show it until you have it; to get it, you have to get it from some *other* Git that has it; that's quite a different proposition. – torek Feb 27 '21 at 08:20
  • 1
    All of this has little to do with making a *new* commit, which is what `git commit` is for. To make a *new* commit, you set up a proposed next commit snapshot—using `git add` to update the current proposal—until you have something you like. You can use `git diff --staged` to compare the *proposed new* commit to the current commit. When this looks right, you run `git commit` and supply a commit message. Git takes the proposed snapshot, adds your name and your log message and so on, and uses all of that to make the new commit: a new snapshot, with metadata saying that you made it, etc. – torek Feb 27 '21 at 08:24
  • 2
    I don't think this involves making a commit. The answer would be `git log -p abc123`. – Schwern Feb 27 '21 at 10:17

0 Answers0