git merge-base HEAD doesn’t return anything?

  Kiến thức lập trình

I’m cloning a certain branch of a repo. I then fetch a second branch. I ultimately want to run merge-base but every time I do it returns nothing:

git-init 
  -url="${PARAM_URL}" 
  -revision="test-branch" 
  -path="${CHECKOUT_DIR}" 
  -depth="1";
cd "${CHECKOUT_DIR}";
git fetch origin dev:refs/remotes/origin/dev;
git switch test-branch;
git merge-base HEAD remotes/origin/dev;

The git merge-base command returns nothing. But it works if I run this:

git merge-base remotes/origin/test-branch remotes/origin/dev

Why is HEAD not registering and how can I get it working with HEAD?

LEAVE A COMMENT