Windows(gitlab为例)系统下git常用操作

来源:互联网 发布:oracle数据库安装教程 编辑:程序博客网 时间:2024/05/18 22:12

1、生成本地密钥

生成本地密钥后,每次链接gitlab就不需要再次链接了,具体操作如下:

    1. git ssh-keygen 仓库地址;    2. 打开“C:\Users\cheng xiaona\.ssh\id_rsa.pub”,并将里面内容复制;    3. 打开GitLab仓库,点击“个人信息”;    4. 点击图标“铅笔”;    5. 左侧列表选择“SSH Keys”;    6. “ADD SSH KEY”--将“id_rsa.pub”里面内容粘贴进文本框“Key”中;    7. 点击按钮“ADD KEY”;

2、gitlab中常见操作

  1. 克隆:git clone 仓库地址;
  2. 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支:

    1. 查看远程分支:git branch -a;2. 查看本地分支:git branch;3. 创建分支:    -*创建一个名为“testBranch”的分支*:git branch testBranch;4. 把本地分支推送到远程分支:git push origin testBranch;5. 把本地所有分支推送到远程:git push --all;5. 切换到“testBranch”分支:    - git branch;    - git checkout testBranch;    - git branch;6. 删除本地分支:git branch -d testBranch7. 删除远程分支:    - git branch -r -d origin/branch-name;    - git push origin :branch-name;
  3. 更新本地

    1. 进入本地目录,gitbash;2. 将这个本地目录变成版本库:git init ;3. 关联远程库:git remote add origin 仓库地址;4. 下载分支内容:git pull origin 分支名;5. 查看代码;
  4. 上传本地:git commit -m '注释说明'
0 0