DCR 2019 Git Workshop
Git workshop for DCR 2019
Local
init
: initialize folder as git repostatus
: see what is going on in the repoadd
: put file(s) into staging areacommit
: commit files from staging areadiff
: see the changes that were made between different files. git diff --staged shows what's different after files are staged- git diff HEAD~2 (show the differences between current and two commits ago)
checkout
: move yourHEAD
aroundHEAD
: where you are currently looking at in historylog
: looking at all your previous messageslog --oneline
: get a one line representation of history
Remotes
remote
: somewhere your git repo is stored (eg, Github)origin
: the default you give your remotepush
: sending local changes to remotepull
: receiving changes from remote
Notes
- git config --list (shows your configs) ls -al (list all hidden files in this folder) nano README.md
git add . vs git add --all git add . is everything in this folder and down git add --all is everything in the repo
Branches
-
`branch : create a new branch
-
checkout <branch-name>
: move to that branch -
checkout -b <branch-name>
: create and move at the same time -
branch -a
: see what branches we have -
log --oneline --graph --decorate --all
: what is going on?- This is a diagram
-
branch -d
: delete a branch that was merged-
branch -D`: force delete a branch that was not merged
Updating history
rebase <branch-name>
: incorporate changes in ,
e.g. master
intro current branch
- You perform this command on the feature branch, not on the master
Exercise
- This is a change to my readme file.