Git Cheatsheet PDF
Git Cheatsheet PDF
Remove le from working directory and add deletion to staging area. Switch working directory to the specied branch. With -b: Git will create the
$ cat .gitignore specied branch if it does not exist.
$ git stash
/logs/*
!logs/.gitkeep Put your current changes into stash. $ git merge [from name]
/tmp
$ git stash pop Join specied [from name] branch into your current branch (the one you are
*.swp
on currenlty).
Thanks to this le Git will ignore all les in logs directory (excluding Apply stored stash content into working directory, and clear stash.
$ git branch -d [name]
the .gitkeep le), whole tmp directory and all les *.swp. Described le $ git stash
statusdrop
ignoring will work for the directory (and children directories) where .gitignore Remove selected branch, if it is already merged into any other. -D instead of
le is placed. Clear stash without applying it into working directory. -d forces deletion.
An overview with references labels and history graph. One commit per line. Create a tag reference named name for current commit. Add commit sha to remote repo remote repo
tag a specic commit instead of current one. (name: origin)
$ git log ref.. (name: public)
$ git tag -a [name] [commit sha]
List commits that are present on current branch and not merged into ref. git fetch git push git push public master
A ref can be e.g. a branch name or a tag name. Create a tag object named name for current commit. or
git pull remote repositories
$ git log ..ref $ git tag -d [name]
local repository
List commit, that are present on ref and not merged into current branch. Remove a tag from a local repository.
repository git commit
$ git reflog
Changes commited here
List operations (like checkouts, commits etc.) made on local repository. 7. REVERTING CHANGES will be safe.
If you are doing backups!
You are doing it, right!?
index
(staging area)
8. SYNCHRONIZING REPOSITORIES $ git reset [--hard] [target reference] git reset HEAD
Switch current branch to the target reference, and leaves a difference as an stash git stash Only index will be
$ git fetch [remote] uncommited changes. When --hard is used, all changes are discarded. committed.
git add Choose wisely
$ git revert [commit sha]
A kind of a shelf git stash pop working what to add!
Fetch changes from the remote, but not update tracking branches. for the mess
you don't want to include. directory
$ git fetch --prune [remote] Create a new commit, reverting changes from the specied commit. It
generates an inversion of changes. You do all the
Remove remote refs, that were removed from the remote repository. hacking right here!
Fetch changes from the remote and merge current branch with its upstream. commit an object D. COMMITS, BRANCHES AND TAGS
$ git push [--tags] [remote] branch a reference to a commit; can have a tracked upstream
origin/x/a
Push local changes to the remote. Use --tags to push tags. tag a reference (standard) or an object (annotated) This is a local branch.
It is 3 commits ahead,
x/a
HEAD a place where your working directory is now
working-version
$ git push -u [remote] [branch] you see it, right?
This is an upstream branch This is also
a local branch
Push local branch to remote repository. Set its copy as an upstream. This is a tag. It looks like a developer's
master
note so it's probably a reference,
not an object.
And this is the past. Here was chaos, This is an initial commit, This is a merge commit,
This is a normal commit,
v1.0.1
HEAD
where no version control was used. it has no parents it has one parent it has two parents!
D o n' t l i v e i n c h a o s ! This is a tag. It looks like a
version so it's probably an object Your working directory
Use Git! is here
(annotated tag)