码迷,mamicode.com
首页 > 其他好文 > 详细

Git 基础 - 克隆远程仓库到本地,修改后推送到远程

时间:2020-02-02 13:56:18      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:信息   rem   clone   tor   ranch   连接   its   util   etc   

 克隆现有的远程仓库到本地

[@wooluwakerdeMBP:gitLab]$ pwd
/Users/walker/work/gitLab

[@wooluwakerdeMBP:gitLab]$ git clone ssh://git@******.git #将远程仓库克隆到本地,会新创建wenjian目录

[@wooluwakerdeMBP:wenjian (master)]$ git remote -v #查看远程信息
origin    ssh://git@******.git (fetch)
origin    ssh://git@******.git (push)

[@wooluwakerdeMBP:gitLab]$ cd wenjian/
[@wooluwakerdeMBP:wenjian (master)]$

[@wooluwakerdeMBP:wenjian (master)]$ echo "2019年_******项目代码" >> REAMME.md

[@wooluwakerdeMBP:wenjian (master)]$ git add .

[@wooluwakerdeMBP:wenjian (master)]$ git commit -m添加项目说明

[@wooluwakerdeMBP:wenjian (master)]$ git push -u origin master #将本地master分支修改的代码提交到远程master分支,-u参数:加上一次之后,后续只需要git push 即可,不需要再加上 origin master 
Branch master set up to track remote branch master from origin.

# 在gitlab 的 web页面上可以看到最新的推送

 

将远程dev分支合并到远程master分支

git checkout -b dev origin/dev #在本地创建并切换到dev分支,并连接到远程的dev分支

[@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ git pull origin dev

[@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ ll # 远程dev分支内容已经pull下来
total 16
drwxr-xr-x  10 walker  staff   320B  2  2 12:59 .
drwxr-xr-x   6 walker  staff   192B  2  2 12:38 ..
-rw-r--r--   1 walker  staff   6.0K  2  2 12:59 .DS_Store
drwxr-xr-x  15 walker  staff   480B  2  2 13:02 .git
-rw-r--r--   1 walker  staff     0B  2  2 12:59 README.md
-rw-r--r--   1 walker  staff     0B  2  2 12:59 __init__.py
drwxr-xr-x   7 walker  staff   224B  2  2 12:59 __pycache__
drwxr-xr-x   9 walker  staff   288B  2  2 12:59 data
drwxr-xr-x   6 walker  staff   192B  2  2 12:59 merge
drwxr-xr-x   8 walker  staff   256B  2  2 12:59 utils

[@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ git checkout master
Switched to branch master
Your branch is up to date with origin/master.

[@wooluwalkerdeMacBook-Pro:wenjian (master)]$ ll # master分支并没有dev分支的内容
total 8
drwxr-xr-x   4 walker  staff   128B  2  2 13:04 .
drwxr-xr-x   6 walker  staff   192B  2  2 12:38 ..
drwxr-xr-x  15 walker  staff   480B  2  2 13:04 .git
-rw-r--r--   1 walker  staff    34B  2  2 13:04 README.md
[@wooluwalkerdeMacBook-Pro:wenjian (master)]$ 

[@wooluwalkerdeMacBook-Pro:wenjian (master)]$ git merge dev #将本地dev分支合并到本地master分支

[@wooluwalkerdeMacBook-Pro:wenjian (master)]$ git status #本地master分支比远程master分支提前
On branch master
Your branch is ahead of origin/master by 4 commits.
  (use "git push" to publish your local commits)

[@wooluwalkerdeMacBook-Pro:wenjian (master)]$ git push # 将本地master分支推送到远程master分支

 

Git 基础 - 克隆远程仓库到本地,修改后推送到远程

标签:信息   rem   clone   tor   ranch   连接   its   util   etc   

原文地址:https://www.cnblogs.com/wooluwalker/p/12251779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!