Git Reference Guide
Introduction to Git
Git is a distributed version control system used to track changes in source code during software development.
Configuration
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
Basic Git Commands
git init: Initializing a Repositorygit clone <repository_URL>: Cloning a Repositorygit add <filename>: Adding Changesgit add -A: Adding ALL Changesgit commit -m "Commit Message": Committing changesgit status: Checking status of current git repogit log: Viewing Commit History
Branching and Merging
git branch <new-branch>: create a new branch based on the current HEADgit branch <new-branch> <base-branch>: create a new branch based on some existing onegit switch <branch-name>: switch togit merge <branch_name>: mergeinto current branch git branch -d <branch_name>: delete
Remote Repositories
Remote repositories are shared locations for storing version controlled code that often allow for collaboration. Examples are GitHub and GitLab.
git remote -v: See linked remote repositories (verbose)git remote add <remote_repository_name> <remote_URL>: add a remote repositorygit push -u <remote_repository_name> <branch_name>: push changes to a remote repositorygit pull <remote_repository_name> <branch_name>: pull changes from a remote repositorygit pull <remote_repository_name> <branch_name> -a: pull all changes from a remote repository, including new branches
Note: If you only have one remote repository called origin, you do not need to include the
; git will use origin by default in most cases.