Modules@robinpath/git
git

@robinpath/git

0.1.1Node.jsPublic

Git version control operations using the system git binary

Git

Git version control operations using the system git binary

Package: @robinpath/git | Category: Devops | Type: Integration

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the git module when you need to:

  • Clone a git repository -- Use git.clone to perform this operation
  • Initialize a new git repository -- Use git.init to perform this operation
  • Get the working tree status -- Use git.status to perform this operation
  • Stage files for commit -- Use git.add to perform this operation
  • Create a commit with the staged changes -- Use git.commit to perform this operation

Quick Reference

FunctionDescriptionReturns
cloneClone a git repositoryobject
initInitialize a new git repositoryobject
statusGet the working tree statusobject
addStage files for commitobject
commitCreate a commit with the staged changesobject
pushPush commits to a remote repositoryobject
pullPull changes from a remote repositoryobject
branchList, create, or delete branchesobject
checkoutSwitch branches or restore working tree filesobject
logShow the commit logobject
diffShow changes between commits, working tree, etc.object
tagCreate or list tagsobject
remoteList remote repositoriesobject
mergeMerge a branch into the current branchobject
stashStash or restore uncommitted changesobject
resetReset the current HEAD to a specified stateobject

Functions

clone

Clone a git repository

Module: git | Returns: object -- API response.

git.clone
ParameterTypeRequiredDescription
urlstringYesRepository URL to clone
deststringNoDestination directory
cwdstringNoWorking directory

init

Initialize a new git repository

Module: git | Returns: object -- API response.

git.init
ParameterTypeRequiredDescription
cwdstringNoDirectory to initialize
barebooleanNoCreate a bare repository

status

Get the working tree status

Module: git | Returns: object -- API response.

git.status
ParameterTypeRequiredDescription
cwdstringNoRepository path
shortbooleanNoShow short status

add

Stage files for commit

Module: git | Returns: object -- API response.

git.add
ParameterTypeRequiredDescription
files`stringstring[]`Yes
cwdstringNoRepository path

commit

Create a commit with the staged changes

Module: git | Returns: object -- API response.

git.commit
ParameterTypeRequiredDescription
messagestringYesCommit message
cwdstringNoRepository path
amendbooleanNoAmend the previous commit

push

Push commits to a remote repository

Module: git | Returns: object -- API response.

git.push
ParameterTypeRequiredDescription
cwdstringNoRepository path
remotestringNoRemote name (default: origin)
branchstringNoBranch to push
forcebooleanNoForce push

pull

Pull changes from a remote repository

Module: git | Returns: object -- API response.

git.pull
ParameterTypeRequiredDescription
cwdstringNoRepository path
remotestringNoRemote name (default: origin)
branchstringNoBranch to pull
rebasebooleanNoRebase instead of merge

branch

List, create, or delete branches

Module: git | Returns: object -- API response.

git.branch
ParameterTypeRequiredDescription
cwdstringNoRepository path
namestringNoBranch name to create (omit to list)
deleteBranchbooleanNoDelete the named branch

checkout

Switch branches or restore working tree files

Module: git | Returns: object -- API response.

git.checkout
ParameterTypeRequiredDescription
targetstringYesBranch or commit to checkout
cwdstringNoRepository path
createbooleanNoCreate a new branch

log

Show the commit log

Module: git | Returns: object -- API response.

git.log
ParameterTypeRequiredDescription
cwdstringNoRepository path
countnumberNoNumber of commits to show (default: 10)
onelinebooleanNoOne line per commit (default: true)

diff

Show changes between commits, working tree, etc.

Module: git | Returns: object -- API response.

git.diff
ParameterTypeRequiredDescription
cwdstringNoRepository path
stagedbooleanNoShow staged changes
refstringNoReference to diff against

tag

Create or list tags

Module: git | Returns: object -- API response.

git.tag
ParameterTypeRequiredDescription
cwdstringNoRepository path
namestringNoTag name (omit to list)
messagestringNoTag message (creates annotated tag)

remote

List remote repositories

Module: git | Returns: object -- API response.

git.remote
ParameterTypeRequiredDescription
cwdstringNoRepository path
verbosebooleanNoShow URLs (default: true)

merge

Merge a branch into the current branch

Module: git | Returns: object -- API response.

git.merge
ParameterTypeRequiredDescription
branchstringYesBranch to merge
cwdstringNoRepository path
noFfbooleanNoCreate a merge commit even for fast-forward

stash

Stash or restore uncommitted changes

Module: git | Returns: object -- API response.

git.stash
ParameterTypeRequiredDescription
cwdstringNoRepository path
actionstringNoAction: push, pop, list, drop, apply (default: push)
messagestringNoStash message (for push)

reset

Reset the current HEAD to a specified state

Module: git | Returns: object -- API response.

git.reset
ParameterTypeRequiredDescription
cwdstringNoRepository path
refstringNoCommit reference (default: HEAD)
modestringNoReset mode: soft, mixed, hard (default: mixed)

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Clone and validate result"
do
  set $result as git.clone
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Create a new item with add

Create a new resource and capture the result.

set $result as git.add
print "Created: " + $result

2. Multi-step Git workflow

Chain multiple git operations together.

@desc "Clone, init, and more"
do
  set $r_clone as git.clone
  set $r_init as git.init
  set $r_status as git.status
  print "All operations complete"
enddo

3. Safe clone with validation

Check results before proceeding.

@desc "Clone and validate result"
do
  set $result as git.clone
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • docker -- Docker module for complementary functionality
  • github -- GitHub module for complementary functionality
  • gitlab -- GitLab module for complementary functionality
  • vercel -- Vercel module for complementary functionality
  • netlify -- Netlify module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/git

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size5.4 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

devops