To get the most from git, you can configure a few of its global settings. In Git Bash, type the following commands: ```bash git config --global user.name <name> git config --global user.email <email> ``` Replace `<name>` and `<email>` with your name and email. Your name and email will be associated with any commits you make (i.e., when you save and publish edits to code). Use `git config --list` to see all settings available to you. ## Git Log The log is helpful when you need to see the history of changes made or roll back to a previous change. These commands help you navigate the logs. | command | effect | | ---- | ---- | |`git log` | all commits | |`git show` | last commit | |`git ls-files` | lists all files that git is tracking | |`git log --oneline --graph --decorate --all` |more detailed history of commits | ### Create an alias for the git history command We'll create a new `hist` command to provide more information when we use it. You can use this pattern to alias other commands as well. In [[Bash]], type: ```bash git config --global alias.hist "log --oneline --graph --decorate --all" ``` Now use `git hist` to see the same command, note it still accepts additional arguments (for example, use `git hist <filename>` to see history for one file). History will be served line by line, type `q` to quit at any time. ## Setup your preferred editor You must provide a message describing your changes when you commit. You can usually type this directly into [[Bash]], but sometimes you'll want to provide a lengthier message. You can set up your default editor for commit messages. This will set up VSCode as the default editor (note that `--wait` is only required for VSCode, and other editors may not require that flag). ```bash git config --global core.editor "code --wait" ``` Type `git config --global -e` to confirm this worked. VSCode should open and display the contents of Git's configuration file. ## Setup Diff & Merge Tool When there are conflicting changes to a file, you'll need to tell Git which changes to keep using Diff and Merge tools. Use the command `git config --global -e` to open Git's global configuration file and paste the following into it: ``` [merge] tool = vscode [mergetool "vscode"] cmd = code --wait $MERGED [diff] tool = vscode [difftool "vscode"] cmd = code --wait --diff $LOCAL $REMOTE ``` > [!NOTE] > You can also use VSCode to compare two files using the command `code --diff <filepath1> <filepath2>`. This option is available from within VSCode through the context menu as well. See [here](https://swcarpentry.github.io/git-novice/02-setup/index.html) for more options on configuring git.