start a git repo from scratch
$ mkdir my_project
$ cd my_project
$ git init
clone a repo
$ git clone path_to_repo
see hidden directory with repo info
$ ls -a
set up git name
$ git config --global user.name your-name
set up git email
$ git config --global user.email your-email
add a file
$ git add file
unstage a file
$ git reset
commit a file
$ git commit -m “commit text”
revert stage
$ git checkout
revert push
$ git checkout HEAD
verschil voor en na stage
$ git diff
verschil voor en na push
$ git diff HEAD
see status / current branch
$ git status
check commit history
$ git log
discard working directory file changes
$ git checkout -- filename
discard all changes in working directory
$ git checkout .
retrieve file from specific commit into stage
$git checkout commit-id filename
check who edited what
git blame filename
show branches and the commit it points to
$ git branch -v
commit log
git log
commit log and show commit summary in one line
git log --oneline
commit log and add branch info
git log --decorate
commit log and include all branches
git log --all
switch to another branch
git checkout otherBranch
what happens when you switch to another branch?
points head to named branch and updates directory
show branches
$ git branch
what does $ git branch do?
it returns branches and puts a * in front of the current branch
create new branch
$ git branch name
create and select new branch
$ git checkout -b name
merge the work on “name” back into master
$ git checkout master
$ git merge name
delete branches
$ git branch -d name
finish merge after conflict
$ git add file
$ git commit
go back after merge conflict
$ git merge --abort
add remote
$ git remote add name id
add reference to repo on remote machine with ‘name’
$ git remote -v
send local commits to remote
$ git push
update our knowledge of the remote
$ git fetch
use remote commits
$ git merge
shortcut for fetch & merge
$ git pull
create local clone
$ git clone link