#git cheatsheet
-
git init
-
git status
-
git diff
compare between working and staging area
-
git commit -m
-
git add
-
git log
- option
- --oneline
- option
- git show HEAD
HEAD: most recently commit output:git log commands for HEAD
- git checkout HEAD
discard the change in working directory, last commited file restored
- git reset HEAD
discard the change in staging directory, last commited file restored * git reset SHA * first 7 characters in SHA needed * to earn SHA,
git log --oneline
- git branch <branch_name>
check, make branch * option * -d <branch_name> : delete branch
- git checkout <branch_name>
change branch
-
how to merge
git checkout master git merge <branch_name>
-
merge conflict
occured when you commited both master and other branch * git marking
```
<<<<<<< HEAD
master version of line
=======
fencing version of line
>>>>>>> fencing
```
* you must delete one
####work flow
- Fetch and merge changes from the remote
- Create a branch to work on a new project feature
- Develop the feature on your branch and commit your work
- Fetch and merge from the remote again (in case new commits were made while you were working)
- Push your branch up to the remote for review
-
git clone <remote_location> <clone_name>
-
git remote
- option
- -v : show all remotes
- option
-
git fetch
fetch is bring from remote, not merging current branch but make origin/master branch and fetched file is in the branch.