[TOC]
參見菜鳥學(xué)院
http://www.runoob.com/git/git-remote-repo.html
重命名遠(yuǎn)程倉庫
http://blog.csdn.net/bitcarmanlee/article/details/51433526
git教程以及在線練習(xí)https://try.github.io/levels/1/challenges/2
install
## ubuntu
$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
libz-dev libssl-dev
$ apt-get install git-core
$ git --version
git version 1.8.1.2
How to use
- git init
- touch test.txt
- git add .
- git commit -m "add a cute file"
- git log
- git remote add origin https://github.com/try-git/try_git.git # 添加遠(yuǎn)程倉庫 贪薪,刪除和查看版本看文張末尾
- git push -u origin master # -u 選項用于記住賬號
diff
- git pull origin master
- git diff HEAD # 比較跟上次commit 的不同
- git push
- git diff --staged # 比較暫存區(qū)跟
撤銷
- git reset octofamily/octodog.txt # 刪除octodog.txt 文件深员,撤銷(unstaged)修改
- git checkout -- octocat.txt # git checkout -- <file> 回到上次commit的地方
分支
- git branch clean_up # 新建一個分支
- git checkout clean_up # 切換到clean_up分支
- git rm '*.txt' # 刪除文件
- git commit -m "remove all"
- git checkout master # 切換到master分支
- git merge clean_up # 把clean_up分支合并到master分支
- git branch -d clean_up # 刪除clean_up分支 git breanch -d <分支名稱>
其他命令
- git remote # 查看遠(yuǎn)程倉庫(按照本地的名字來分)
- git remote -v # 查看版本
- git remote rm <remote repo name> # 刪除遠(yuǎn)程倉庫
branch 操作
重命名分支
git branch -m <old-name> <new-name>
-
本地創(chuàng)建分支葱轩,推送到遠(yuǎn)程
- git branch <branchName>
- git checkout <branchName>
- git push origin <branchName>
git branch # 查看分支 本刽,本地
git branch -a # 查看所有分支,包括本地和遠(yuǎn)程
git branch -d <分支名稱> # 刪除本地的分支
git push origin --delete <分支名稱> # 刪除遠(yuǎn)程分支
git fetch -p <倉庫名稱,不帶分分支># 刪除remote沒有超燃,但是本地有的分支
git fetch # 同步遠(yuǎn)程的分支到本地聘萨,如果遠(yuǎn)程有课竣,本地沒有挟鸠,則本地會生成
git diff # 查看當(dāng)前工作區(qū)和上次commit的倉庫(本地倉庫)的差別