git 常用命令

 

git 文件名乱码 http://zengrong.net/post/1249.htm

git config –global core.quotepath false  

 

当前分支打包 http://web.mit.edu/~thefred/MacData/afs/sipb/project/git/git-doc/git-archive.html

git archive --format=tar -o latest.tar.gz HEAD  

 

克隆 master

git clone <git_url>  

 

克隆远程分支

git clone --branch <remote_branch_name> <git_url>  
git clone <git_url> -b <remote_branch_name>   

 

查看所有分支

git branch -a  

 

更新 remote 索引

git fetch   

 

显示对应的克隆地址

git remote -v  

 

查看远程仓库信息

git remote show origin  

 

查看所有分支

git branch -r  

 

列出仓库中所有的头

git show-ref  

 

打补丁

git apply ***.diff  

 

提交分支数据到远程服务器

git push origin <local_branch_name>:<remote_branch_name>  

 

分支再建分支

git branch new-branch-name origin/old-branch-name  

 

提交master分支数据到远程服务器

git push origin HEAD:master  

 

添加一个新分支

git branch <branch_name>  
git checkout <branch_name>  
git push origin <remote_branch_name>  

 

添加一个已存在远程分支的分支

git clone ***  
git fetch origin  
git branch dev refs/remotes/origin/dev 或 git branch dev -b  

 

删除本地分支

git branch -d <local_branch_name>  

 

删除远程分支

git push origin :<remote_branch_name>  

 

cat .git/config

[core]  
    repositoryformatversion = 0  
    filemode = true  
    bare = false  
    logallrefupdates = true  
[remote "origin"]  
    fetch = +refs/heads/*:refs/remotes/origin/*  
    url = git+ssh://git@git.***.com/***  
[branch "master"]  
    remote = origin  
    merge = refs/heads/master  
[branch "develop"]  
    remote = origin  
    merge = refs/heads/develop  

 

管理配置

 
[group dev-team]  
writable = projects  
members = uesrs  
  
[group readonly]  
writable = projects  
members = users  
  
[group project_readonly]  
readonly = project  
members = user  

引用 http://progit.org/book/zh/

posted @ 2012-11-08 04:12  yondy  阅读(286)  评论(0编辑  收藏  举报