FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

nodegit/guides/repositories/initializing at bump-libssh2 · PB-Tech/nodegit · GitHub

Repository navigation

Latest commit

 

History

History
 
 
  1. nodegit
  2. guides
  3. repositories

initializing

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

layout full
menu_item guides
title Initializing
description How to initialize a repository

In order to run examples, you will need to Install NodeGit first.

Return to all guides


Initializing a Repository

This guide explains how to create a new repository.

View example source

Requiring NodeGit

In the guides directory, we like to keep our NodeGit relative to the project root.

var NodeGit = require("../../../");

However, in your project you will most likely be using the following command:

var NodeGit = require("nodegit");

Arguments to initialize a repo

There are 2 arguments to the init method, a path to initialize the repo in and whether or not to make a .git subfolder in that directory or use the passed in directory as the .git folder itself.

var pathToRepo = require("path").resolve("../my-git-projects/my-project");
var isBare = 0; // lets create a .git subfolder

Initialize the Repo

Now that we have our arguments we can call the init method on the NodeGit.Repository module to create the repo.

NodeGit.Repository.init(pathToRepo, isBare).then(function (repo) {
  // In this function we have a repo object that we can perform git operations
  // on.

  // Note that with a new repository many functions will fail until there is
  // an initial commit.
});

Back | FazBrowse Home | New Git URL