Skip to content

Commit

Permalink
Use git reset instead of git pull to avoid attempting a merge commit
Browse files Browse the repository at this point in the history
Also, use git remote set-head in case the repository’s default branch
has been renamed.

Fixes yarnpkg#5303.

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Mar 9, 2021
1 parent 3119382 commit f907fff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ export default class Git implements GitRefResolvingInterface {
return fs.lockQueue.push(gitUrl.repository, async () => {
if (await fs.exists(cwd)) {
await spawnGit(['fetch', '--tags'], {cwd});
await spawnGit(['pull'], {cwd});
await spawnGit(['remote', 'set-head', 'origin', '--auto'], {cwd});
await spawnGit(['reset', '--hard', 'origin/HEAD'], {cwd});
} else {
await spawnGit(['clone', gitUrl.repository, cwd]);
}
Expand Down

0 comments on commit f907fff

Please sign in to comment.