Git and git hub

  • Published on
    03-Sep-2014

  • View
    900

  • Download
    11

Embed Size (px)

DESCRIPTION

A simple introduction for basic use of git and git hub. Since I'm a rookie to Git, If there is anything wrong, please contact me. Hope you'll enjoy it.

Transcript

  • Git and Git Hub
  • Whats Git
  • Whats version control? code?
  • Whats version control? code? !!! GameCode!!!
  • Whats version control? code? !!! GameCode!!! ?
  • Whats version control? code? !!! GameCode!!! ?
  • Whats version control? code? !!! GameCode!!! ? Git
  • Before start Git
  • Install Git For Linux Fedora yum install git-core Debian, Ubuntu sudo apt-get install git
  • Install Git For Mac MacPorts sudo port install git-core +svn +doc +bash_completion +gitweb MacPorts http://www.macports.org/ brew brew install git brew http://brew.sh/
  • Install Git For Windows http://msysgit.github.com/ !
  • Set e-mail and name email git hub bitbucket push repounknown git config --global user.name " git config --global user.email "" e.g. git config --global user.name user git config --global user.email user@user
  • Set alias -> !!! git config --global alias."command alias" "original command alias git config --global alias.st status git config --global alias.cmt commit git config --global alias.cmtm "commit m" git config global alias.br branch
  • Seting git git config -- global l
  • Lets start a repo in local Whats repo repository git ()git git init
  • Lets start a repo in local
  • Lets start a repo in local .git!!! git
  • Lets start a repo in local .git!!! git oh my zsh
  • Stage git status aliasstatus st git st git(stage)
  • Stage 4 0. untracked (git) 1. unmodified (add commit) 2. modified (add ) 3. staged (commit )
  • Stage - staged git ()
  • Stage - untracked hi.txt untracked
  • Stage - unmodified filegit git add file name
  • Stage - modified ? 2
  • Stage - modified ? git add . add
  • Stage - staged
  • Stage - staged stage!!! git commit commit git config global core.editor=vim
  • Stage - staged commit git commit m your commit for this change
  • Stage - staged commit ? ? !!!
  • Stage - staged commit? git commit --amend commit
  • Stage - staged staged commit git log q
  • Stage - modified add git add
  • Stage => track (git add) => (git commit) => => stage (git add) => ( git commit ) =>
  • Restore commit git checkout file name" modified (add) git reset file name
  • Restore commit?
  • Restore commit? git reset commit SHA commitSHA
  • Restore first commit!!! commitfirst commit git checkout hi2.txt commithi2.txt
  • Restore reset? reset git reflog reset
  • Restore SHA? Gitncommit HEAD : commit HEAD~1 : commit HEAD~n : n+1commit git reset HEAD~n
  • Restore ? git reset HEAD~n file name checkoutcommit resetcommit checkout ???
  • Reset V.S Checkout hi2.txtfourth commit hi2.txtsecond commit
  • Reset V.S Checkout 1. hi2.txt
  • Reset V.S Checkout 1. hi2.txt 2. reset (second commit)
  • Reset V.S Checkout 1. hi2.txt 3. hi2.txt 2. reset (second commit)
  • Reset V.S Checkout 1. hi2.txt 3. hi2.txt 2. reset (second commit) 4. checkout
  • Reset V.S Checkout 1. hi2.txt 3. hi2.txt 2. reset (second commit) 4. checkout 5. second commit
  • Ignore file git? !!! echo "filename" > .gitignore .gitignoregit e.g. aFolderb : echo aFolder/b > .gitignore .gitignore./
  • Ignore file ignorefile? !!!!! git rm --cache file name ignore
  • Rename(move) and delete files git git rm "filename" git mv original filename new filename Linux
  • Branch Git code !!!
  • Branch () git branch branch name" git checkout branch name"
  • Merge branchbranch git merge branch name branchmastermerge branch git branch d branch name mergerbranch git branch D branch name
  • Git Hub What is Git Hub p.s.
  • Create a repo in Git Hub
  • Create a repo in Git Hub repoCreate repository!!!
  • Create a repo in Git Hub
  • Push your repo Push -> git hub git originrepo~ touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/Lee-W/tryGit.git git push -u origin master
  • Push your repo git remote add origin Your repo git push -u origin master git remoterepo git push u origin mastermastergit hub branch
  • What should be in a repo readme readme markdown Git Hub markdown Git hub Favored Markdown readme.md git hub google!!!
  • Download a repo 1.repo -> Clone a repo 2.repo -> Pull a repo
  • Clone a repo ()repo git clone repo url
  • Pull a repo repo remoterepo git pull
  • Pull a branch in a remote repo reporepo git fetch origin git pull origin branch_name
  • Other Remote Operation remote git remote -v remote git remote rm origin remote git remote add origin URL
  • Other resource git 1. Git 2. Git 3. Git Git 1.8 (iHower) 4. 30 Git 5. Pro GIT () 6. Try Git () 7. Learn Git Branching ()