Skip to content

Instantly share code, notes, and snippets.

@bowmanjd
Last active January 15, 2021 13:34
Show Gist options
  • Save bowmanjd/14d5df511548a39cd5c53dff4f3df3f5 to your computer and use it in GitHub Desktop.
Save bowmanjd/14d5df511548a39cd5c53dff4f3df3f5 to your computer and use it in GitHub Desktop.
Adds two functions for instantiating dotfile management with git
# Set-ExecutionPolicy RemoteSigned -scope CurrentUser
# iwr -useb https://gist.githubusercontent.com/bowmanjd/14d5df511548a39cd5c53dff4f3df3f5/raw/61ac0e7b2298789bc4b35d988597989c15dadf62/dotfiles-ps.ps1 | iex
function dtfnew
{
Param ([string]$repo)
git init -b base
git remote add origin $repo
# Uncomment one of the following 3 lines
git config --local status.showUntrackedFiles no
# echo '/**' >> .git/info/exclude
# echo '/**' >> .gitignore; git add -f .gitignore
echo "Please add and commit additional files, then run"
echo "git push -u origin base"
}
function dtfrestore {
Param ([string]$repo)
git init -b base
git remote add origin $repo
# Uncomment one of the following 2 lines unless repo has '/**' line in a .gitignore
git config --local status.showUntrackedFiles no
# echo '/**' >> .git/info/exclude
git fetch --set-upstream origin base
git switch --no-overwrite-ignore base
if (-not $?) {
echo "Deal with conflicting files, then run (possibly with -f flag if you are OK with overwriting)`ngit switch base"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment