Promotes changes to the Git staging area so they can be saved during the next commit.
Add-GitItem [-Path] <String> [[-RepoRoot] <String>] [-PassThru] [<CommonParameters>]
Add-GitItem function promotes new/untracked and modified files to the Git staging area. When committing changes, by default Git only commits changes that have been staged. Use this function on each file you want to commit before committing. No other files will be committed.
PassThru switch to get
IO.DirectoryInfo objects back for each file and directory added, respectively. If the items are already added or were unmodified and not added to the staging area, you'll still get objects back for them.
This function implements the
git add command.
|Name||Type||Description||Required?||Pipeline Input||Default Value|
The paths to the files/directories to add to the next commit.
|true||true (ByValue, ByPropertyName)|
The path to the repository where the files should be added. The default is the current directory as returned by Get-Location.
Add-GitItem -Path 'C:\Projects\LibGit2'
Demonstrates how to add all the items under a directory to the next commit to the repository in the current directory.
Add-GitItem -Path 'C:\Projects\LibGit2\Functions\Add-GitItem.ps1','C:\Projects\LibGit2\Tests\Add-GitItem.Tests.ps1'
Demonstrates how to add multiple items and files to the next commit.
Get-ChildItem '.\LibGit2\Functions','.\Tests' | Add-GitItem
Demonstrates that you can pipe paths or file system objects to Add-GitItem. When passing directories, all untracked/new or modified files under that directory are added. When passing files, only that file is added.
Add-GitItem -Path 'C:\Projects\LibGit2' -RepoRoot 'C:\Projects\LibGit2'
Demonstrates how to operate on a repository that isn't the current directory.
Get-ChildItem | Add-GitItem
Demonstrates that you can pipe
IO.DirectoryInfo objects to
Add-GitItem. Plain strings are also allowed.
Add-GitItem -Path 'file1','directory1' -PassThru
Demonstrates how to get
IO.DirectoryInfo objects returned for each file and directory, respectively.