GIT基本操做命令

一 简单操做步骤:
git clone git@xxxxx:project_name
git checkout -b new_branch
---修改代码
git commit –m’test’
---修改代码
git stash
git checkout master
git pull origin master
git merge new_branch
git push origin mastergit

二 GIT命令:windows

  1. clone
     下载源码,至关于SVN 首次checkout
     git clone git://xxx/project_name.git new_pro_namebash

  2. add 将文件加入到版本管理中
     add 操做过的文件才会被 commit
     git add file服务器

  3. Pull 更新源码,至关于SVN updateless

  4. Push 提交代码,至关于SVN commit
    git push --set-upstream origin branch_nameui

  5. checkout 分支建立,切换
     git checkout –b new_branch 切换并建立branch
     git checkout new_branch 切换到新branch编码

  6. branch 分支操做,包括删除等
     git branch -d/D new_branch 删除分支,-D
     git branch -v 列出当前分支url

  7. commit 提交代码,
     提交在本地,并不上传至服务器,上传到服务器须要push 或 remote命令
     git commit –m’备注内容’ 默认不写备注内容没法提交.net

  8. merge 合并操做,分支合并
     git merge barnch1 在当前分支将branch1 分支合并进来code

  9. stash 暂存
     git stash
     git stash pop [--index] 取出最后一次stash代码
     git stash list 列出stash存储列表

  10. remote 远程操做/服务器操做
     git remote add [shortname] [url] //添加远程仓库
     git remote -v //列出远程仓库
     git remote rm [remote-name] //删除远程仓库

  11. tag 标签
     git tag v1 //创建标签

  12. config 设置配置
     git config --global core.autocrlf false // windows 下禁 git自动修改换行

$ git config --global core.quotepath false          # 显示 status 编码  
$ git config --global gui.encoding utf-8            # 图形界面编码  
$ git config --global i18n.commit.encoding utf-8    # 提交信息编码  
$ git config --global i18n.logoutputencoding utf-8  # 输出 log 编码  
$ export LESSCHARSET=utf-8  
# 最后一条命令是由于 git log 默认使用 less 分页,因此须要 bash 对 less 命令进行 utf-8 编码

三 .gitignore 文件
注释为 #注释

四 参考文档 Git帮助文档: http://git-scm.com/docs 书籍: progit中文.pdf

相关文章
相关标签/搜索