5

git 的基本操作

 2 years ago
source link: https://blog.51cto.com/u_12638289/5586136
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

git 的基本操作

精选 原创

宇无敌ing 2022-08-17 12:04:13 ©著作权

文章标签 git 文章分类 研发管理 软件研发 阅读数268

场景区分:

一、本地无仓库,首次从远程库中拉代码

1.新建本地文件夹,并进入该文件夹下初始化仓库,git init

2.首次本地与远程仓库建立密钥连接

   (1)本地仓库创建SSH Key

       $ssh-keygen -t rsa -C "​ ​[email protected]​"

       主目录--.ssh目录,id_rsa是私钥,不能泄露,将id_rsa.pub公钥共享

(2)在远程仓库中添加本地仓库生成的公钥

 3. 本地仓库添加远程仓库

    git remote add 仓库别名 远程仓库SSH或http地址

4.从远程仓库拉代码

    git clone 远程仓库SSH或者http地址

二、日常往远程仓库提交代码

      git add .  将所有文件添加到暂存区

      git commit -m "备注" 将暂存区内容添加到仓库中

      git push 远程仓库名 本地分支名:远程分支名(若相同可省略)将本地仓库分支推送到远程仓库分支

三、分支管理

创建dev分支: git branch dev 

切换到dev分支:git checkout dev

创建并切换到dev分支:git checkout -b dev

  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK