zoukankan      html  css  js  c++  java
  • git工具使用

    参考
    https://help.coding.net/docs/host/git/installation.html  
    https://www.jianshu.com/p/81143ef6c97f
    //打开git终端
    
    Git 分支管理
    本地分支管理
    $ git checkout -b learn-checkout  //创建并切换到分支
    $ git branch learn-branch    //单独创建分支  新建一个名为『learn-branch』的分支
    $ git branch      //创建完分支之后使用git branch命令查看分支
    $ git checkout learn-branch    //使用git checkout 『分支名称』
    
    分支与标签
    $ git branch                   #显示所有本地分支
    $ git checkout <branch/tag>    #切换到指定分支和标签
    $ git branch <new-branch>      #创建新分支
    $ git branch -d <branch>       #删除本地分支
    $ git tag                      #列出所有本地标签
    $ git tag <tagname>            #基于最新提交创建标签
    $ git tag -d <tagname>         #删除标签
    
    合并与衍合
    $ git merge <branch>        #合并指定分支到当前分支
    $ git rebase <branch>       #衍合指定分支到当前分支
    
    远程操作
    $ git remote -v                   #查看远程版本库信息
    $ git remote show <remote>        #查看指定远程版本库信息
    $ git remote add <remote> <url>   #添加远程版本库
    $ git fetch <remote>              #从远程库获取代码
    $ git pull <remote> <branch>      #下载代码及快速合并
    $ git push <remote> <branch>      #上传代码及快速合并
    $ git push <remote> :<branch/tag-name>  #删除远程分支或标签
    $ git push --tags                       #上传所有标签
    
    本地仓库
    
    创建本地仓库
    $ mkdir my_project   //创建项目目录
    $ cd my_project
    $ git init         //初始化库 //切换路径到目标目录,执行:$ git init命令
    $ git clone https://e.coding.net/team-name/learn-git.git   //克隆远程仓库到本地
    
    远程仓库
    $ git remote add learn-git git@e.coding.net:coding/Coding-Feedback.git  //git remote add 『remote-name』『url』 
    //『remote-name』是给远程仓库起的别名,一般是『origin』
    $ git remote -v                   //git remote 命令来查看当前添加的远程仓库
    $ git fetch 『remote-name』       //从远程仓库抓取数据到本地
    $ git push learn-git master       //会将本地的仓库数据推送到远程仓库的『master』分支         git push 『remote-name』『branch-name』
    $ git remote rename learn-git origin            //重命名远程仓库     把 learn-git 改成 origin
    $ git remote rm origin                        //解除和远程仓库『origin』的关联
    
    $ git add readme.txt
    $ git add readme.txt learn_git.txt
    $ git add .    //添加当前仓库里的所有文件   
    
    $ git commit -m "wrote a readme and a learn_git file"            ///用git commit命令把文件提交到仓库,一次性会提交所有你已经添加的文件
    
    
    Git 常用命令速查表
    创建版本库
    $ git clone <url>                  #克隆远程版本库
    $ git init                         #初始化本地版本库
    修改和提交
    $ git status                       #查看状态
    $ git diff                         #查看变更内容
    $ git add .                        #跟踪所有改动过的文件
    $ git add <file>                   #跟踪指定的文件
    $ git mv <old><new>                #文件改名
    $ git rm<file>                     #删除文件
    $ git rm --cached<file>            #停止跟踪文件但不删除
    $ git commit -m "commit messages"  #提交所有更新过的文件
    $ git commit --amend               #修改最后一次改动
    查看提交历史
    $ git log                    #查看提交历史
    $ git log -p <file>          #查看指定文件的提交历史
    $ git blame <file>           #以列表方式查看指定文件的提交历史
    撤销
    $ git reset --hard HEAD      #撤销工作目录中所有未提交文件的修改内容
    $ git checkout HEAD <file>   #撤销指定的未提交文件的修改内容
    $ git revert <commit>        #撤销指定的提交
    $ git log --before="1 days"  #退回到之前1天的版本
    分支与标签
    $ git branch                   #显示所有本地分支
    $ git checkout <branch/tag>    #切换到指定分支和标签
    $ git branch <new-branch>      #创建新分支
    $ git branch -d <branch>       #删除本地分支
    $ git tag                      #列出所有本地标签
    $ git tag <tagname>            #基于最新提交创建标签
    $ git tag -d <tagname>         #删除标签
    合并与衍合
    $ git merge <branch>        #合并指定分支到当前分支
    $ git rebase <branch>       #衍合指定分支到当前分支
    远程操作
    $ git remote -v                   #查看远程版本库信息
    $ git remote show <remote>        #查看指定远程版本库信息
    $ git remote add <remote> <url>   #添加远程版本库
    $ git fetch <remote>              #从远程库获取代码
    $ git pull <remote> <branch>      #下载代码及快速合并
    $ git push <remote> <branch>      #上传代码及快速合并
    $ git push <remote> :<branch/tag-name>  #删除远程分支或标签
    $ git push --tags                       #上传所有标签

     git push origin :refs/tags/2.6.2    //删除远程标签

    git branch -a             //查看项目分支(包括本地和远程)

    git branch -d 分支名        //删除本地分支

    git push origin –delete 分支名     //删除远程分支

    git checkout branchName   //切换到新分支

    git branch branchName     //创建新分支

    git checkout -b branchName    // 创建 切换到新分支

    使用 Git 管理文件时,每次结束工作前请依次执行git addgit commitgit push命令将文件推送到 CODING 远程仓库。

  • 相关阅读:
    程序活动记录&程序调试&多线程编程
    数据结构与算法
    C/C++
    Information Retrieval --- Retrieval Comment
    Information Retrieval --- Clustering
    Information Retrieval --- Classification
    Information Retrieval --- Web Search
    Information Retrieval --- Retrieval Enforce:Relevance Feedback & Query Expansion
    Information Retrieval --- Retrieval Model
    ubuntu server 安装vnc
  • 原文地址:https://www.cnblogs.com/lovebay/p/12451542.html
Copyright © 2011-2022 走看看