# Git Commands 101: A Comprehensive Guide Git is a distributed version control system widely used for tracking changes in source code during software development. This guide introduces basic Git operations, configurations for SSL verification, and password caching, as well as branch management and other essential commands. ## Configuring Git Settings - **Set SSL Verify to False:** To disable SSL certificate verification for HTTP connections: `git config --global http.sslVerify false` - **Set Password Caching:** To cache your password in memory for a specified period (in seconds): `git config --global credential.helper "cache --timeout=8000"` ## Basic Git Operations - **Initialize a New Git Repository:** `git init` - **Clone a Repository:** `git clone <repository-url>` - **Add Files to Staging Area:** `git add <file>` - **Commit Changes:** `git commit -m "Commit message"` - **Push Changes to Remote Repository:** `git push origin <branch-name>` - **Pull Changes from Remote Repository:** `git pull origin <branch-name>` - **Check Status:** `git status` - **View Commit History:** `git log` ## Branch Management - **Create a New Branch:** `git branch <branch-name>` Creates a new branch but does not switch to it. - **Switch to a Branch:** `git checkout <branch-name>` Switches to the specified branch. - **Create and Switch to a New Branch:** `git checkout -b <branch-name>` Creates a new branch and immediately switches to it. - **List All Branches:** `git branch` Lists all local branches. Use `git branch -a` to list both local and remote branches. - **Merge a Branch:** `git merge <branch-name>` Merges the specified branch into the current branch. - **Delete a Branch:** - Local branch: `git branch -d <branch-name>` - Remote branch: `git push origin --delete <branch-name>` ## Advanced Configurations and Tips - **Changing a Remote's URL:** `git remote set-url origin <new-repository-url>` - **Stashing Changes:** `git stash` - **Applying Stashed Changes:** `git stash apply` - **Rebasing:** `git rebase <base-branch>` Applies changes from the current branch onto the `<base-branch>`, which can be used to maintain a linear project history. - **Viewing Changes:** `git diff` Shows the differences not yet staged. - **Undoing Changes:** `git checkout -- <file>` Reverts changes to a file to its last committed state. - **Creating an All Remote:** ```.git/config # Below your other remotes [remote "all"] url = (url to first remote) url = (url to second remote) ``` This guide covers essential Git commands for version control, including branch management and merging, which are crucial for collaborative development projects. As you become more familiar with these operations, they will significantly enhance your ability to manage complex codebases and workflows.