Skip to content

Latest commit

 

History

History
89 lines (61 loc) · 1.78 KB

git.md

File metadata and controls

89 lines (61 loc) · 1.78 KB

#git cheatsheet

git workflows

image of git work space

basic commands

  1. git init

  2. git status

  3. git diff

compare between working and staging area

  1. git commit -m

  2. git add

  3. git log

    • option
      • --oneline

Backtracking

  1. git show HEAD

HEAD: most recently commit output:git log commands for HEAD

  1. git checkout HEAD

discard the change in working directory, last commited file restored

  1. 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

Branching

git branching

  1. git branch <branch_name>

check, make branch * option * -d <branch_name> : delete branch

  1. git checkout <branch_name>

change branch

  1. how to merge

    git checkout master
    git merge <branch_name>
    
  2. 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 together

####work flow

  1. Fetch and merge changes from the remote
  2. Create a branch to work on a new project feature
  3. Develop the feature on your branch and commit your work
  4. Fetch and merge from the remote again (in case new commits were made while you were working)
  5. Push your branch up to the remote for review
  1. git clone <remote_location> <clone_name>

  2. git remote

    • option
      • -v : show all remotes
  3. git fetch

fetch is bring from remote, not merging current branch but make origin/master branch and fetched file is in the branch.