Lot of good tips here, but inside Powershell I could not get it to work.
I am a .NET developer and we mainly still use Windows OS as we haven't made use of .Net core and cross platform so much, so my everyday use with Git is in a Windows environment, where the shell used is more often Powershell and not Git bash.
The following procedure can be followed to create an aliased function for adding untracked files in a Git repository.
Inside your $profile file of Powershell (in case it is missing - you can run:
New-Item $Profile)
notepad $Profile
Now add this Powershell method:
function AddUntracked-Git() {
&git ls-files -o --exclude-standard | select | foreach { git add $_ }
}
Save the $profile file and reload it into Powershell.
Then reload your $profile file with:
. $profile
This is similar to the source command in *nix environments IMHO.
So next time you, if you are developer using Powershell in Windows against Git repo
and want to just include untracked files you can run:
AddUntracked-Git
This follows the Powershell convention where you have verb-nouns.
.gitignore
is specifically engineered for that purpose, notgit add -u
. – Molina