Home > Mobile >  How to tell if a commit belongs to a local project
How to tell if a commit belongs to a local project

Time:11-28

Let's say we have two sessions -sessionOne and sessionTwo. I used sessionOne two create an initial project that has two commits and push this project to github remote:

enter image description here

Then I (as another user) use sessionTwo to clone this Github repository to local and then I modify a file and create a commit locally:

enter image description here

Then I switch to seesionOne and create a third commit then push change to remote:

enter image description here

Now I switch to sessionTwo and pull from the remote, since I (on behalf of another user ) made changes on existing on seesionTwo before, there is confilct and so I fix the conflict and git adds a merge change, then I push changes to remote as: enter image description here

Now my question is, when I use sessionOne to do git pull, I gets a same output which is very similar to above:

enter image description here

the "modify sth" commit is originally from sessionTwo, but in sessionOne's Sourcetree output, it is colored in blue, after long time, I might think this is the change I made after a long time when I quickly look at the graph.

CodePudding user response:

Commits don't "belong" to any particular repo, whether that repo is the origin, upstream, some other remote or a local clone. Git does not explicitly track which repo introduced the commit. The things git tracks for each commit are:

  1. the commit hash
  2. the state of all the files in the repo as of that commit.
  3. it's parent commit(s)
  4. the commit author
  5. the committer
  6. the author date
  7. the commit date
  8. the commit message

There might be some other things I missed, but there is nothing about which repo the commit came from.

  • Related