0

I am supposed to debug an issue where prowjob have issue checking out to a specific commit f74e42a

prow script:

git init
git remote add origin <upstream repo>.git
if [ -z "$branch" ]; then
    git fetch origin
    git checkout -f $sha
elif [ -z "$sha" ]; then
    git fetch origin +ref/heads/$branch
    git checkout -b $branch origin/$branch
else
    git fetch origin +refs/heads/$branch:
    git checkout $sha -b $branch
fi

The issues comes from the checkout

prow log:

Initialized empty Git repository in /tmp/git/.git/
From <repo>
 * branch        master  -> FETCH_HEAD
 * [new branch]  master  -> origin/master
fatal: reference is not a tree : f74e42a

Note: the git commit f74e42a exist in the source code repo pr. The commit f74e42a is a local fork repo commit.

Additional notes: I am new to git and have no idea where to start debugging. I have research and most possible reasons are:

  1. someone else force push, overriding the f74e42a commit.
  2. commit was squash
  3. Inside, out (ref)

I am tasked to edit the prow script, and I tried this where someone at the end mention a fix with git pull --all, I tried it but still face same error

JustAG33K
  • 776
  • 5
  • 17
R. Elliot
  • 61
  • 1
  • 7
  • Or is it even possible to checkout a fork repo local commit sha? – R. Elliot May 30 '22 at 06:28
  • You must *have* the commit before you can check it out. If you already have the commit in the local repository, you're good, otherwise you must connect your Git (software+repo) to some other Git (software+repo) that *does* have it and get it. You'll need either a name (branch or tag name, usually) that *reaches* the commit, or the *full hash ID;* `f74e42a` is abbreviated and will not suffice. – torek May 30 '22 at 07:13
  • I don't understand how can `f74e42a` be a local fork and exist on the source repo. Can you clarify this ? What is the command line you did ? – Ôrel May 30 '22 at 07:21
  • Add `git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*` after `git remote add origin .git`. Otherwise `git fetch origin` does not work as you expected. – ElpieKay May 30 '22 at 07:46

0 Answers0