Git guide

来源:互联网 发布:h5 红包页面源码 编辑:程序博客网 时间:2024/06/02 06:42

GIT GUIDE

目录

 
  • 1 How to download code source form remote
  • 2 How to create new branch in local and remote
  • 3 How to delete a branch in local or remote
  • 4 How to delete a tag in local or remote
  • 5 How to fetch remote code
  • 6 How to commit and push your first code
  • 7 How to merge code

How to download code source form remote

  • git clone git://host.xz[:port]/path/to/repo.git/

如 git@git.yourdomain.com:app/app-server.git

How to create new branch in local and remote

create branch in local

  • git branch XXX origin/master

XXX: your branch name origin/master: which remote master you want to branch from.

enter XXX branch in local

  • git checkout XXX

create branch to remote

  • git push origin XXX

How to delete a branch in local or remote

delete local branch

  • git branch -D XXX

delete remote branch

  • git push origin :XXX

How to delete a tag in local or remote

delete tag in local

  • git tag -d YYY

delete tag to remote

  • git push origin :refs/tags/YYY

YYY: tag name

How to fetch remote code

  • git checkout XXX
  • git fetch
  • git merge
  • git pull == git fetch + git merge

How to commit and push your first code

add a new file first.sh

  • git add .
  • git commit
  • git push

How to merge code

merge code from remote branch X to branch Y and then push to remote

enter branch Y in local

  • git checkout Y

merge code from remote branch X

  • git merge origin/X

push the code to remote

  • git push origin Y
  • How to move a repository to another place using command

    • git clone --mirror git://gitorious.org/weasyprint/weasyprint.git weasyprint
    • git fetch
    • git remote add github git@github.com:SimonSapin/WeasyPrint.git
    • git push --mirror github

原创粉丝点击