A while ago one of my team members cloned my code by using
git clone --bare -l /home/jaimemontoya/public_html/app/public.git /home/johndoe/app/public.git
He continued coding and when he uses git remote -v
he gets this:
origin ssh://[email protected]/home/johndoe/app.git (fetch)
origin ssh://[email protected]/home/johndoe/app.git (push)
He had the latest code so at one point I wanted to get the latest version of his code by using this:
git clone --progress -v "ssh://[email protected]/home/johndoe/app.git" "C:\Users\jaimemontoya\Apps\Marketing\app"
To my surprise, when I navigate to C:\Users\jaimemontoya\Apps\Marketing\app
and use git log -1
, I'm getting a very old commit, not the most recent one that my team member has when he uses git log -1
from his local. He claims to have already pushed to remote, meaning ssh://[email protected]/home/johndoe/app.git
should already have his latest code so that when I clone from it, I should also be able to fetch the latest. My first guess is that he may not have pushed to remote. But assuming he has already done it, what could explain why I'm not being able to retrieve the latest code from ssh://[email protected]/home/johndoe/app.git
?
Note: I used root
to try to explore ssh://[email protected]/home/johndoe/app.git
and see what I get:
[email protected] [~]# cd ../home/johndoe/app.git/
[email protected] [app.git]# ls -al
total 68
..................
..................
drwxr-x--x 5 johndoe gitgrp 4096 Nov 25 2021 app
..................
..................
drwxr-x--x 7 johndoe gitgroup 4096 Nov 25 2021 .git
..................
..................
[email protected] [androidapp.git]# git log -1
I'm still seeing an old commit, not the latest one that my team member claims to have already pushed to remote. This happens even after logging in as root
to the server where the code is being hosted. This is a bare repository. However, shouldn't .git
list the latest code pushed to ssh://[email protected]/home/johndoe/app.git
, when use use git log -1
from /home/johndoe/app.git/
on the server where the remote repository is hosted? Thank you.
CodePudding user response:
git log
by default shows the history for the HEAD
. So git log -1
is simply showing you the commit pointed to by HEAD
ref. Most likely your team member's latest code was pushed onto a branch other than the one pointed to by HEAD
, or for some reason HEAD
in the remote repo was not updated to point to the latest commit they pushed.
You can verify this with the following command either on the remote or your clone of the remote:
git log --graph --pretty=format:'%C(yellow)%h%Creset %Cgreen(