Skip to content

Initial branch name on repo creation (Resolves #102) #115

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,20 @@ export class Git extends EventEmitter implements GitEvents {
* Create a new bare repository `repoName` in the instance repository directory.
* @param repo - the name of the repo
* @param callback - Optionally get a callback `cb(err)` to be notified when the repository was created.
* @param initialBranch - optional name for the initial branch of the repo (instead of using the user's git config)
*/
create(repo: string, callback: (error?: Error) => void) {
create(repo: string, callback: (error?: Error) => void, initialBranch?: string) {
function next(self: Git) {
let ps;
let _error = '';

const dir = self.dirMap(repo);
const gitArgs: string[] = ['init'];

if (self.checkout) {
ps = spawn('git', ['init', dir]);
} else {
ps = spawn('git', ['init', '--bare', dir]);
}
initialBranch && gitArgs.push('-b', initialBranch);
!self.checkout && gitArgs.push('--bare');

ps = spawn('git', [...gitArgs, dir]);

ps.stderr.on('data', function (chunk: string) {
_error += chunk;
Expand Down