git config --global --includes --get user.name
git config --global --includes --get core.autocrlf
But
git config --global --includes --get user.email
More on user.email later
All these settings are stored in ~/.gitconfig
- Empty directory
- Set up demo editor snippets with
wget -P .vscode https://raw.githubusercontent.com/PaperCutSoftware/git-from-powershell/main/.vscode/demo-snippets.code-snippets
- Set up demo editor snippets with
- Add a first file (ex1)
Get-ChildItemgit status- Create a new Git repo (project)
git init Get-ChildItemGet-ChildItem -Forcegit statusgit add <file>git statusgit commit- OOps --
git log git config user.email alecclews@gmail.comgit commit --amend --reset-authorgit log
Ta Da! We have a project under version control
Add directories and files to a magic file called .gitignore
For example
Write-Output "/.vscode/" > .gitignoregit statusNow.vscodeis ignored, but.gitignoreis not trackedgit add .gitignoregit commit -m "Added gitignore file"git status
It's normal, good practice, to add the .gitignore file to the project repo.
However you should also configure a "core.excludesfile"
config setting with a list of your local
IDE and editor specific "cruft" files that others do not need to be aware of.
The project .gitignore is then for files that everyone will see (e.g. build artefacts)
- Update our file
ex2 - Test
- Fix
git statusgit diffgit add .git statusgit commit -m "Added comment blockgit log
- Add a spurious file
Write-Output "some stuff" > file2 git add file2git commit -m "Silly file"
- Stage the file delete with
git rm file2 - Rename the report file with
git mv report.ps1 papercut-report.ps1 git statusgit commit
git show HEAD and git show HEAD^^
Create a special version of Epson plugin
- Show all our branches
git branch --all - Create a new branch
git checkout -b epson - Do some work (ex3)
- Test
- Commit
- Do some work (ex4)
- Test
- Commit
git logandgitk --allshow two commits for one piece of work
Skip on first read
10. Combine last two commits -- make it clean git rebase -i HEAD^^
11. See git log gitk
git checkout main- add in some changes (ex5)
- Test
- add and commit
git ci -am "Add more info and make it pretty" - use
gitk --allto see branches
- Checkout
epsonbranchgit checkout epson - Merge in changes from master
git merge master - Lines clash - see
git status - Manually merge using markers
- test
git add papercut-report.ps1git statusgit commit -m "made epson version pretty"gitk --all- Switch back to main
git checkout -(-is an alias for "the previous branch") gitk -all--epsonhas changes frommain, butmaindoes not have changes fromepson
- Make sure we are on the
epsonbranchgit checkout epson - Make sure the current root working directory is clean,
git status - Now rebase current work on top of
main - Fix any problems manually, test, and use
git add <...>,git rebase --continueif required
- Check out branch
main, i.e.git checkout main - And merge
git merge epson-- no conflicts because we did all that jazz during the rebase. Note "fast forward" - Test
- Delete merged branch
git branch -f epson
git tag rel-1- Move to somewhere else in the commit tree
git checkout HEAD~5 - Go back to our tag -- "a rock in a sea of change"
git checkout rel-1
- Create an account on GitHib
- Make sure GitHub CLI tool is installed (
choco install gh) - Create repo from command line
gh repo create --public - Push our code to GitHub
git push --set-upstream origin main - Now open
start https://github.com/<userName>/git-demo