Install Git on macOS
Install Git using Homebrew:
Verify the installation was successful:
Configure your Git username and email
Set your default text editor for editing your commit messages
More Information about the Credential Storage.
How to use KeyChain on macOS to store git credentials
On macOS you can use the KeyChain with
git-credential-osxkeychain. It’s automatic installed if you install git with homebrew. The osxkeychain mode caches credentials in the secure keychain that’s attached to your system account. This method stores the credentials on disk, and they never expire, but they’re encrypted with the same system that stores HTTPS certificates and Safari auto-fills.
Set osxkeychain as default Credential Storage for your credentials:
How to use the Git Credential Manager for Windows
If you’re using Windows, you can install a helper called “Git Credential Manager for Windows.” This is similar to the “osxkeychain” helper described above, but uses the Windows Credential Store to control sensitive information.
It can be found at https://github.com/Microsoft/Git-Credential-Manager-for-Windows.
Set the Git-Credential-Manager as default Credential Storage for your credentials:
Draw a text-based graphical representation of the commit history on the left hand side of the output.
Git Head vs Index vs Working Directory
Git reset vs checkout
Git reset and
checkout both updates the HEAD, Index and Working Directory branches.
git checkout [branch] is pretty similar to running
git reset --hard [branch] in that it updates all three trees for you to look like
[branch], but there are two important differences:
checkoutis working-directory safe; it will check to make sure it’s not blowing away files that have changes to them. Actually, it’s a bit smarter than that — it tries to do a trivial merge in the working directory, so all of the files you haven’t changed will be updated.
reset --hard, on the other hand, will simply replace everything across the board without checking.
- The second important difference is how
checkoutupdates HEAD. Whereas
resetwill move the branch that HEAD points to,
checkoutwill move HEAD itself to point to another branch.