git 常用

  • Cmder 集成工具, 可以使用别名

  • 命令:

git branch

git checkout <branchname>

git status

git add .

git commit -m 'gitmessage'

git push

  • 生成公钥: ssh-keygen -t rsa -C "youremail"

  • 配置账户:

git config --global user.name <username>

git config --global user.email <useremail>

  • 远端:

查看远端仓库: git remote -v

克隆修改文件夹名字: git clone <repo> <filename>,

  • filename 为本地文件夹名, 将内容克隆到这个文件夹
  • git clone git@github.com:xn213/blog.git public 远端为blog的项目克隆到 public 下

Problems:

  1. 问题:gitlab 配置了SSH key,但是每次提交的时候还是要输入用户名和密码

    • 原因:第一次拉取代码的时候用的是 http 方式拉取的,配置 SSH 的key只针对 SSH 提交有用

    • 解决: git remote set-url origin <SSH_URL>

    • 注: SSH_URLSSH模式下的项目地址