isomorphic-git / isomorphic-git/isomorphic-git

Change branch then to push not work

Open
#1,029 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8.4k
Forks
491
Avg merge
2h 53m
Merged PRs (30d)
7

Description

I use it in electron main process, and I use `dist/for-node/isomorphic-git/index`.
it's ok when normal push, but if i checkout other branch then to push, it's not work the first push.

the code:

```javascript
/**
* Check whether the branch needs to be switched
*/
async checkCurrentBranch() {
const { setting } = this.db
const currentBranch = await git.currentBranch({ fs, dir: this.outputDir, fullname: false })
const localBranches = await git.listBranches({ fs, dir: this.outputDir })

if (currentBranch !== setting.branch) {
if (!localBranches.includes(setting.branch)) {
await git.branch({ fs, dir: this.outputDir, ref: setting.branch })
}

await git.fastCheckout({ fs, dir: this.outputDir, ref: setting.branch })
}
}
```
```javascript
await this.checkCurrentBranch()
const pushRes = await git.push({
fs,
dir: this.outputDir,
remote: 'origin',
ref: setting.branch,
force: true,
})
console.log('pushRes', pushRes)
```
when currentBranch is `master`, setting.branch is `gh-pages`, the pushRes is return ok, but it's not push log

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.