您的位置:首页 > 其它

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

2017-01-04 13:46 302 查看

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中常见操作

克隆:git clone 仓库地址;

查看远程分支、本地分支、创建分支、把分支推到远程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 testBranch
7. 删除远程分支:
- git branch -r -d origin/branch-name;
- git push origin :branch-name;


更新本地
1. 进入本地目录,gitbash;
2. 将这个本地目录变成版本库:git init ;
3. 关联远程库:git remote add origin 仓库地址;
4. 下载分支内容:git pull origin 分支名;
5. 查看代码;


上传本地:git commit -m '注释说明'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: