isomorphic-git / isomorphic-git/isomorphic-git
Change branch then to push not work
- 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
Assessment
This issue has not been assessed yet.