关于git:Git远程操作

1次阅读

共计 674 个字符,预计需要花费 2 分钟才能阅读完成。

1. 上传本地代码库到近程仓库

git init # 创立本地仓库
git remote add origin ssh://git@gitlab.csc.com.cn:1022/wugang/test-remote.git # 设置近程仓库地址 git add . # 给本地仓库增加文件
git commit -m ‘feat: 测试推送本地仓库 DEVOPS-13’ # 给本地仓库增加
git push -u origin master # 将本地的 master 分支推动到近程仓库

2. 下载近程代码库

git clone ssh://git@gitlab.csc.com.cn:1022/csc-it/itplan/devops/devops-util.git

3. 下载近程分支

git branch -a
git checkout -b f-devops-12 origin/f-devops-12 # 第一次下载分支

4. 更新近程分支到本地

git fetch # 同步近程仓库,否则无奈看到近程分支名 git fetch origin f-1 # 更新近程分支
git checkout f-1 # 切换到本地分支 f -1
git fetch origin master # 从近程的 origin 仓库的 master 分支下载代码到本地的 origin master
git pull origin master # 拉取近程分支更新到本地仓库,与本地以后分支进行合并 git pull = git fetch + git merge

5. 上传近程分支

git push origin f-2 # 将本地分支上传到近程仓库

6.git 本地关联近程分支

git branch –set-upstream-to=origin/f-1 f1

正文完
 0