GIT Cheat Sheet 2
GIT Cheat Sheet 2
GitHub Desktop
desktop.github.com
git-scm.com
Configure tooling
Configure user information for all local repositories
Branches
Branches are an important part of working with Git. Any commits you make will be made on the
branch you’re currently “checked out” to. Use git status to see which branch that is.
Create repositories
A new repository can either be created locally, or an existing repository can be cloned. When a
repository was initialized locally, you have to push it to GitHub afterwards.
$ git init
The git init command turns an existing directory into a new Git repository inside the folder you
are running this command. After using the git init command, link the local repository to an
empty GitHub repository using the following command:
Specifies the remote repository for your local repository. The url points to a repository on
GitHub.
Clone (download) a repository that already exists on GitHub, including all of the files, branches,
and commits
Synchronize changes
Synchronize your local repository with the remote repository on GitHub.com
$ git fetch
$ git merge
Combines remote tracking branches into current local branch
$ git push
$ git pull
Updates your current local working branch with all new commits from the corresponding remote
branch on GitHub. git pull is a combination of git fetch and git merge
Make changes
Browse and inspect the evolution of project files
$ git log
Lists version history for a file, beyond renames (works only for a single file)
Redo commits
Erase mistakes and craft replacement history
CAUTION! Changing history can have nasty side effects. If you need to change commits that
exist on GitHub (the remote), proceed with caution. If you need help, reach out at
github.community or contact support.
Glossary
git: an open source, distributed version-control system
GitHub: a platform for hosting and collaborating on Git repositories
commit: a Git object, a snapshot of your entire repository compressed into a SHA
branch: a lightweight movable pointer to a commit
clone: a local version of a repository, including all commits and branches
remote: a common repository on GitHub that all team members use to exchange their
changes
fork: a copy of a repository on GitHub owned by a different user
pull request: a place to compare and discuss the differences introduced on a branch with
reviews, comments, integrated tests, and more
HEAD: representing your current working directory, the HEAD pointer can be moved to
different branches, tags, or commits when using git switch