2. Git completion
● Installing git completion
http://yon.ir/gitcom
● Using it in general
● Using it on git add
Git Intermediate Course
3. Stashing your changes
● Git stash [save]
● Git stash apply
● Git stash list
● Git stash show
Git Intermediate Course
4. ● Git log
● See commit changes with -p
● See changes of a certain file or directory with [--
filename]
● See a list of commit messages and commit
hashes --pretty=oneline
Viewing commit logs
Git Intermediate Course
5. HEAD pointer
● HEAD always points to the tip of currently
selected branch
● For example when you’re on master branch,
HEAD is pointing to the last commit that it can
find on the client machine
Git Intermediate Course
6. Difference of a file with repo
● Git diff
● See differences of a specific file/folder with
[filename]
● See differences of staged changes with [--
staged]
Git Intermediate Course
7. Remove a file from repo
● Git rm
● Force removing (disable diff checking) with -f
OR --force
● Recursive removal of files in a directory with -r
Git Intermediate Course
8. Ignoring files from repo
● Wherever we need to ignore a file from repo we
need to do 2 things:
1. the file(s) shouldn’t be in the repo (or should be
deleted)
2. after that we need to add the file path to .gitignore
file
● Usually happens with cached files, minified
assets
● .gitkeep
Git Intermediate Course
9. Undoing changes
● Git reset
● Git reset <path>
● Imagine you just commited a few changes and
made a mistake?! Use the command below
only if you haven’t pushed the commit yet:
Git reset HEAD^n --soft
● “n” is the number of commits to rollback
Git Intermediate Course
10. Branching
● “Git branch [--list]” is for getting a list of branches
● “Git branch -a” show all remote and local branches
● “Git branch <branchname>” is to create a new
branch
git push --set-upstream origin dev-master
● “Git checkout -b <new-branch>” create and switch
to new branch
Git Intermediate Course
11. Branching – Part 2
● Git branch [(-d|-D)] <branch-name> to delete a
branch
● “Git checkout <branch-name>” switch between
branches
● “Git branch -m <new-name>” rename currently
used branch
Git Intermediate Course
12. Merging
● “Git merge <branch-name>” merge <branch-
name> to current branch
● This command uses local branch data to
perform merging
● --commit and --no-commit flags
Git Intermediate Course
15. Conflict!!!
● Hunk is a continuous area of changed lines,
made by a developer on a file.
● Upon merge, if git was unable to merge either
of the files, it will the file as conflict.
● It happens when any of the hunks have any
lines in common.
Git Intermediate Course
17. Strategies on reducing conflicts
● Don’t change the white spaces.
● Keep lines short.
● Keep commits small and focused.
● Merge often
● Track changes to master
Git Intermediate Course