See the git-intro cheatsheet for the basics.
.git
directory: there are no files actually checked out. Directory names
usually like something.git
This excludes most introduced in the git-intro cheatsheet.
Setup:
git clone <url> [<target-directory>]
: Make a copy of existing
repository at <url>, containing all history.Status:
git status
: Same as in basic git, list statusgit remote [-v]
: List all remotesgit graph
: see a detailed graph of commits. Create this command
with git config --global alias.graph "log --all --graph --decorate --oneline"
General work:
git checkout <branch-name>
: Make a branch active.git push [<remote-name>] [<branch>:<branch>]
: Send commits and
update the branch on the remote.git pull [<remote-name>] [<branch-name>]
: Fetch and then merge
automatically. Can be convenient, but to be careful you can fetch
and merge separately.git fetch [<remote-name>]
: Get commits from the remote. Doesn’t
update local branches, but updates the remote tracking branches
(like origin/NAME).git merge [<branch-name>]
: Updates your current branch with
changes from another branch. By default, merges to the branch is is
tracking by default.git remote add <remote-name> <url>
: Adds a new remote with a
certain name.