zoukankan      html  css  js  c++  java
  • git基础

    一. 撤销git add的文件

    git add xx命令可以将xx文件添加到暂存区,如果有很多改动可以通过 git add -A .来一次添加所有改变的文件。

    注意 -A 选项后面还有一个句点。 git add -A表示添加所有内容, git add . 表示添加新文件和编辑过的文件不包括删除的文件; git add -u 表示添加编辑或者删除的文件,不包括新添加的文件。

     撤销git add 的文件,将暂存区stage中的文件删除:

     git rm -r --cached .

     二. 初始化git仓库

    Git global setup
    git config --global user.name "maoyu"
    git config --global user.email "88888888@qq.com"
    
    Create a new repository
    git clone git@gitlab.com:guojiang/grab.git
    cd grab
    touch README.md
    git add README.md
    git commit -m "add README"
    git push -u origin master
    
    Existing folder
    cd existing_folder
    git init
    git remote add origin git@gitlab.com:guojiang/grab.git
    git add .
    git commit -m "Initial commit"
    git push -u origin master
    
    Existing Git repository
    cd existing_repo
    git remote rename origin old-origin
    git remote add origin git@gitlab.com:guojiang/grab.git
    git push -u origin --all
    git push -u origin --tags

    三. 克隆指定远程分支

    git clone -b xxx(分支名) git@gitlab.com:saysmy/test.git

    例如:
    git clone -b release/test git@gitlab.com:gj-frontend/xingguang.git;

    常见问题:

    Could not open a connection to your authentication agent

    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.

    如果确定公钥已经放到github或者gitlab等,那么运行下面的命令检查下:

     cat .git/config

    是否远程仓库地址不对?

     ssh-add -l

    如果提示  Could not open a connection to your authentication agent.  运行  ssh-agent bash , 再执行下面的。

    如果提示The agent has no identities.则需要把私钥加到ssh-agent ssesion中:

    ssh-add ~/.ssh/gitlab_id_rsa

    再运行 ssh-add -l  发现加入成功:

    2048 a3:2f:8c:9b:2b:ae:d4:23:9b:c6:47:4e:94:47:38:c2 /root/.ssh/gitlab_id_rsa (RSA)
  • 相关阅读:
    Win32基础知识2 Win32汇编语言003
    Win32基础知识4 Win32汇编语言005
    Win32基础知识4 Win32汇编语言005
    第一个程序 零基础入门学习Delphi01
    Mysql四种通信协议(linux下本地连接的都是socket 其他都是tcp)
    Rhino
    Common Gateway Interface Python CGI编程
    inaccessible
    mysqli_report
    算法功底网站性能瓶颈
  • 原文地址:https://www.cnblogs.com/saysmy/p/6702656.html
Copyright © 2011-2022 走看看