=======
git-command-line
A wrapper for command line git with promises
How to use it
Git-command-line is a wrapper for command line Git so, you must have git installed in your linux / mac machine (it has not been tested in windows yet).
- Common sintax is:
var GitCommandLine = ;var Git = '/tmp/gitTemp';//You can also create it only with GitCommandLine() and set the working path laterGitgit commandstring parameters options ;
=======
Some examples
- To Git init /tmp/git folder, add all files on it, commit, add a new remote and push master to it
var GitCommandLine = ; //Variables var gitFolder = '/tmp/gitTemp'; var remoteName = 'origin'; var remoteUrl = 'https://example.remote.repo'; //Create a new Git object var Git = gitFolder; //Execute the chain Git ;
- To commit staged files with message "My commit" on the last working folder if any or current one
Git ;
=======
API
Initially, following commands are available:
- add Add file contents to the index
- bisect Find by binary search the change that introduced a bug
- branch List, create, or delete branches
- checkout Checkout a branch or paths to the working tree
- clone Clone a repository into a new directory
- commit Record changes to the repository
- diff Show changes between commits, commit and working tree, etc
- direct Allows the direct execution of a git command that is not available in the API yet
- fetch Download objects and refs from another repository
- grep Print lines matching a pattern
- init Create an empty Git repository or reinitialize an existing one
- log Show commit logs
- merge Join two or more development histories together
- mv Move or rename a file, a directory, or a symlink
- pull Fetch from and integrate with another repository or a local branch
- push Update remote refs along with associated objects
- rebase Forward-port local commits to the updated upstream head
- remote Manage set of tracked repositories
- reset Reset current HEAD to the specified state
- rm Remove files from the working tree and from the index
- show Show various types of objects
- status Show the working tree status
- tag Create, list, delete or verify a tag object signed with GPG
- setWorkingDirectory Sets the working path for the following git commands
- getWorkingDirectory Returns the current working path
- setLog Sets the logging of the Git command line responses
- getLog Returns the state of the logging
Options parameter is to tweak the 'exec' command as described in: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
There is a special situation. Once you stablish cwd in the options param, it will be maintained through the rest of the commands
Direct
Git.direct(command,options);
Git direct allows the direct execution of a Git command that is not available in the API yet
- Examples
var myGitRepo = '/tmp/gitTemp'; //This is where the command will be executed var Git = myGitRepo; Git ;
Add
Git.add(command, options)
Same as 'git add [command]'
- To add all files in /tmp/git and the commit them
Git
Bisect
Git.bisect(command, options);
Same as 'git bisect [command]'
Branch
Git.branch(command, options);
Same as 'git branch [command]'
- To get current branch
Git
Checkout
Git.checkout(command, options);
Same as 'git checkout [command]'
- To change to branch test
Git;
Clone
Git.clone(command, options);
Same as 'git clone [command]'
- To clone a git repo on current folder
Git;
- To clone a git repo on /tmp
Git;
Commit
Git.commit(command, options);
Same as 'git commit [command]'
- Examples
var myGitRepo = '/tmp/gitTemp'; //This is where the command will be executed var Git = myGitRepo; Git //Equivalent to 'git commit -m "My commit"' ;
Diff
Git.diff(command, options);
Same as 'git diff [command]'
Fetch
Git.fetch(command, options);
Same as 'git fetch [command]'
Grep
Git.grep(command, options);
Same as 'git grep [command]'
Init
Git.init(command, options);
Same as 'git init [command]'
Log
Git.log(command, options);
Same as 'git log [command]'
Merge
Git.merge(command, options);
Same as 'git merge [command]'
MV
Git.mv(command, options);
Same as 'git mv [command]'
Pull
Git.pull(command, options);
Same as 'git pull [command]'
Push
Git.push(command, options);
Same as 'git push [command]'
Rebase
Git.rebase(command, options);
Same as 'git rebase [command]'
Remote
Git.remote(command, options);
Same as 'git remote [command]'
Reset
Git.reset(command, options);
Same as 'git reset [command]'
RM
Git.rm(command, options);
Same as 'git rm [command]'
Show
Git.show(command, options);
Same as 'git show [command]' or simple 'git show' if no param specified
Status
Git.status(command, options);
Same as 'git status [command]' or simply 'git status' if no param specified
- Examples
Gitstatus ; //Or... Gitstatus'-h' ;
Tag
Git.tag(command, options);
Same as 'git tag [command]'
- Examples
Git