Install Git.
git config --global user.name "Your Name Here"
git config --global user.email your@email.com
On a specific repository, navigate to the specific repository:
git config user.name "Your Name Here"
git config user.email your@email.com
The editor is used to edit commit messages. I like using vim
, you don't need to install it as it is included in Git Bash
.
Vim supports:
- Highlighting the first line of the commit in yellow and shift to grey when more than 50 characters
- You can configure it to wrap:
git config --global core.editor vim
git config --global format.commitMessageColumns 72
git config --global core.editor notepad
Inside notepad
: View
=> Status Bar
(so you can see which column you're on currently).
If you absolutely want to you can use Notepad++
but line wrapping will not work.
git config --global core.editor "'C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
The Git Credential Manager Core (GCM Core) is now included in Git for Windows.
GCM Core supports multi-factor authentication for Azure DevOps, GitHub, and Bitbucket.
If you're using multiple accounts on a provider and the accounts can't be differentiated by the hostname only you'll need to instruct Git to pass the entire repository URL, rather than just the hostname:
git config --global credential.useHttpPath true
This will prompt you for your credentials for each repository (see documentation).
git config --global alias.st "status"
git config --global alias.lg "log --pretty='%Cred%h%Creset | %s %Cgreen(%cr)%Creset %C(cyan)[%an]%Creset'"
git config --global alias.lg-graph-s "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all"
git config --global alias.lg-graph-l "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
git switch -
git log -1 -- <file-path>
Note: this is particularly useful when looking for the commit that deleted a file.
If you only know the file name, you can use wild cards:
git log -1 -- '**/<file-name>'
git fetch origin --prune
Before fetching, remove any remote-tracking references that no longer exist on the remote.
You can edit your global config with the following command:
git config --global --edit
I recommend adding those settings:
[core]
editor = vim -c'startinsert|norm! ggA' - vim will start in INSERT mode
[push]
default = simple
followTags = true - Instead of manually pushing new tags with --follow-tags, you always send your annotated tags up along with a git push.
[status]
showUntrackedFiles = all - shows you all the files underneath that new directory during a git status
git config --global core.longpaths true
Open Edit Group Policy
:
Spend some time understanding the reasoning used to design these flows. When deciding on a branching strategy, take into consideration the team's Git
maturity level, how you're currently releasing software, and how you would like to release software.
Name | Main characteristic |
---|---|
git-flow | When you need to support multiple production versions. |
GitHub Flow | Once your Pull Request is approved, you branch is deployed to production before being merged to main . |
OneFlow | A simpler alternative to git-flow. |
Trunk based development | Pair-programming and no Pull Request. |
Martin Fowler wrote a lengthy piece named Patterns for Managing Source Code Branches favouring trunk based development, it does a good job explaining the different branching strategies.
- 💰 Git Fundamentals (Pluralsight)
- 💰 How Git Works (Pluralsight)
- 💰 Advanced Git Tips and Tricks (Pluralsight)
- The Things Git Can Do (that none of the GUIs have ever told you about)