zoukankan      html  css  js  c++  java
  • Git 常用命令

    git 操作:

      拉代码:git clone http|ssh代码克隆地址

      拉取分支:git clone -b 分支名 http|ssh代码克隆地址

      提交代码:

        ①git status(对比代码库与本地有什么区别)

        ②git add .(上传代码)

        ③git commit -m "新功能描述"(注释)

        ④git push 远程主机名 分支名(提交代码,不写主机名和分支名,默认提交至主干)

      常用命令:

        git branch -a  查看本地和远程主机的全部分支 

        vim .git/config 在项目根目录下修改远程仓库地址

        git remote -v 查看当前配置的远程仓库地址

        git checkout -b ccs-test origin/ccs-test  切换到ccs-test分支(默认是在master分支)

        git push -u origin develop  把代码推到远程主机的develop分支

        # git pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。

        git pull origin master:master #取回origin主机的master分支,与本地的master分支合并

    提交代码到代码库时报错:

    *** Please tell me who you are.
    
    Run
    
      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"
    
    to set your account's default identity.
    Omit --global to set the identity only in this repository.
    
    fatal: unable to auto-detect email address (got 'min@min-PC.(none)')

    通过配置邮箱地址和用户名解决:

      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"

    在windows系统提交代码或拉代码无需每次输入账号密码:

      在个人电脑上有时候懒得输入git的账号密码,可以使用此方法一劳永逸,不过这样账号同时也存在风险。 首先电脑上已经装了Git GUI 或者Git Bash,然后使用Win+R 键盘打开 运行 窗口,输入 %USERPROFILE% 回车。 这时候在该目录下有个.gitconfig的隐藏文件,使用文本编辑器打开,在底下添加如下两行:

    [credential]
    helper=store

      然后当下次输入账号密码后,Git会自动将信息保存在此目录的.git-credentials文件中,往后就不必重复输入了。

  • 相关阅读:
    java file文件类操作使用方法大全
    java 中可以在方法中 新建 方法吗
    java InputStream读取数据问题
    file 创建方法
    java中File类的使用方法
    jquery怎么获取radio的值
    //初始化无限滚动分页组件
    表单提交 封装成json格式
    几个常用EL表达式的用法
    简单的顺序队列
  • 原文地址:https://www.cnblogs.com/cpw6/p/12066777.html
Copyright © 2011-2022 走看看