Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Incorrect fetch for baseRef #109

Merged
merged 1 commit into from
Sep 27, 2024
Merged

fix: Incorrect fetch for baseRef #109

merged 1 commit into from
Sep 27, 2024

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented May 9, 2024

/usr/bin/git fetch -n origin main
  From https://github.com/preactjs/preact
   * branch              main       -> FETCH_HEAD
   * [new branch]        main       -> origin/main
  successfully fetched base.ref
  checking out and building base commit
  /usr/bin/git reset --hard main
  fatal: ambiguous argument 'main': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

As the repo is a shallow clone, fetches will only update the remote branch tracking the currently cloned branch, i.e., git fetch <another branch> won't have any effect. Providing a local branch to track the remote from will fix this, however.

Simple demonstration of the issue:

git clone git@github.com:preactjs/preact.git --depth=1
cd preact
git fetch -n origin v11 # fetch will succeed, but not affect the repo
git reset --hard v11 # will fail with the same error as shown above

git fetch -n origin v11:v11
git reset --hard v11 # will succeed

Copy link

github-actions bot commented May 9, 2024

Size Change: 0 B

Total Size: 75.6 kB

ℹ️ View Unchanged
Filename Size
index.js 75.6 kB

compressed-size-action

@rschristian rschristian merged commit 4a35a53 into master Sep 27, 2024
2 checks passed
@rschristian rschristian deleted the rschristian-patch-1 branch September 27, 2024 07:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants