git-help =============== Git简单使用说明 ## 初步 **新仓库**,初始化 ```shell git init git remote add origin http://url.git git commit -m "import" git push -u origin master ``` **已有仓库**,添加远程 ```shell git remote add third http://url.git git push -u third master git commit -m "update" git push ``` ### 签出代码库 ```shell git clone http://url.git dirName git checkout origin git commit -m "modify" git push ``` ## 分支 ### 创建分支 ```shell git branch branchName git branch -m 改名字 (如果有同名會失敗,改用 -M 可以強制覆蓋) ``` ### 切换分支 ```shell git checkout branchName ``` > 注意:如果你有檔案修改了卻還沒 commit,會不能切換 branch ```shell git checkout -b () 本地建立 branch 並立即 checkout 切換過去 ``` ### 删除分支 删除远程分支 ```shell git push origin --delete git branch -d -r branchname 删除远程branchname分支 git push origin :branch-name 推送一个空分支到远程分支,其实就相当于删除远程分支 ``` ## 标签版本(Tag) 显示本地Tag ```shell git tag ``` - 0.6.7 - 0.6.8 - 0.8.0 ### 添加tag ```shell git tag '0.8.0' git tag -a 0.8.0 -m "comment" ``` ### 推送Tag到远程 ```shell git push --tag ``` ### 删除本地tag ```shell git tag -d 0.8.0 ``` Deleted tag '0.8.0' (was 126095d) ### 删除远程tag ```shell git push origin --delete tag git push origin :refs/tags/0.8.0 #推送一个空tag到远程tag remote: Updating references: 100% (1/1) To http://zhenqin-pro102/git/katta.git - [deleted] 0.8.0 ```