从私有git服务器拉取时,每当我在VS Code中创建分支时,它都不会跟踪上游分支。git输出显示它正在运行
git checkout -q -b NewBranchLocal --no-track origin/NewBranch
如果我使用">Git: Checkout to...“或">Git:创建分支自...“命令。
有没有从git服务器中提取这些文件的最佳实践?我如何使用VS Code中的git扩展来创建原始分支的本地版本,并将其绑定到上游分支?
根据我在VS Code的源代码中所看到的,似乎只有当您正在创建的分支正在被签出时,才应该显示--no-track,但是我没有看到一个选项,您可以创建一个分支而不签出它。查看vscode-master/extensions/git/src文件夹,git.ts (1238行)说
async branch(name: string, checkout: boolean, ref?: string): Promise<void> {
const args = checkout ? ['checkout', '-q', '-b', name, '--no-track'] : ['branch', '-q', name];
if (ref) {
args.push(ref);
}
await this.run(args);
}
唯一的引用在repository.ts中(979行):
async branch(name: string, _checkout: boolean, _ref?: string): Promise<void> {
await this.run(Operation.Branch, () => this.repository.branch(name, _checkout, _ref));
}
这是在commands.ts文件中调用的(1563行)
private async _branch(repository: Repository, defaultName?: string, from = false): Promise<void> {
const branchName = await this.promptForBranchName(defaultName);
if (!branchName) {
return;
}
let target = 'HEAD';
if (from) {
const picks = [new HEADItem(repository), ...createCheckoutItems(repository)];
const placeHolder = localize('select a ref to create a new branch from', 'Select a ref to create the \'{0}\' branch from', branchName);
const choice = await window.showQuickPick(picks, { placeHolder });
if (!choice) {
return;
}
target = choice.label;
}
await repository.branch(branchName, true, target);
}
因此,没有能力不检查该分支,也没有机会将新的本地分支链接到源。
我在vscode-master项目中找不到任何其他的引用,所以我不知道下一步该去哪里看。
发布于 2020-08-10 19:53:54
根据this VS Code issue的说法,Git:结账到...命令将显示分支的列表。如果你选择一个远程分支,它将创建一个本地分支,并将其设置为跟踪远程分支。我刚刚用VS Code 1.47.3测试了这一点,它创建了带有跟踪的本地分支。也许在你把问题贴在这里之后,他们修复了这个问题?
https://stackoverflow.com/questions/57699396
复制相似问题