Git 分布式版本控制系统、创建分支,跳转分支、git拉取、在码云上创建项目,进行pull 和 push、克隆码云上任意项目

news/2024/9/22 18:24:43/

目录

1.Git 分布式版本控制系统:

git-toc" style="margin-left:40px;">1.安装git

2.创建目录,进行初始化

3.写入Java文件,提交文件

4.文件放入仓库

git%E6%93%8D%E4%BD%9C%E9%83%BD%E5%BA%94%E8%AF%A5%E5%B7%A5%E4%BD%9C%E5%9C%A8%EF%BC%8C%E6%8C%87%E5%AE%9A%E7%9A%84init%20%E7%9B%AE%E5%BD%95%E4%B8%8B%E8%BF%9B%E8%A1%8C%EF%BC%89-toc" style="margin-left:0px;">2.创建分支,跳转分支(所有的git操作都应该工作在,指定的init 目录下进行)

1.分支共享(不提交)

2.合并,先切换到主分支

3.删除分支

4.创造分支合并冲突

5.主分支和newbranch都有修改,并进行合并

6.解决冲突:

git%E6%8B%89%E5%8F%96-toc" style="margin-left:0px;">3.git拉取

git-toc" style="margin-left:40px;">        1.在客户端cli主机,安装git

git%E4%B8%BB%E6%9C%BA%EF%BC%9A-toc" style="margin-left:40px;">        2.免密链接git主机:

git%E4%B8%BB%E6%9C%BA%E4%B8%AD%E7%9A%84yy000%E7%9B%AE%E5%BD%95-toc" style="margin-left:40px;">        3.克隆git主机中的yy000目录

        4.检查:

        5.修改内容,设置自己的账号和邮箱

4.在码云上创建项目,进行pull 和 push:

1.初始化目录:

2.回到cli客户端,克隆项目中内容

3.创建文件:

4.提交:

5.在码云上实现:

6.编辑文件内容:

7.在码云页面查看:

5.克隆码云上任意项目:


1.Git 分布式版本控制系统:

git">1.安装git

[root@13git ~]# yum -y install git

2.创建目录,进行初始化

[root@13git ~]# mkdir /yy000

[root@13git ~]# cd /yy000/
[root@13git yy000]# ls
[root@13git yy000]# git init 
初始化空的 Git 版本库于 /yy000/.git/

[root@13git yy000]# ls -a
.  ..  .git
[root@13git yy000]# cd .git/
[root@13git .git]# ls
branches  config  description  HEAD  hooks  info  objects  refs
[root@13git .git]# cd ..

3.写入Java文件,提交文件

[root@13git yy000]# vim test.java

public class Test{
        public static void main(String [] args){
                System.out.println("hello world");
        }
}

4.文件放入仓库

[root@13git yy000]# git log
fatal: bad default revision 'HEAD'
[root@13git yy000]# git add test.java
[root@13git yy000]# git commit -m "新增了一个test.Java文件"

[root@13git yy000]# git config --global user.name shisi
[root@13git yy000]# git config --global user.email mm@shisi.com
[root@13git yy000]# echo "你好世界" >> test.java 
[root@13git yy000]# git add .
[root@13git yy000]# git commit -m "第二次"
[master(根提交) c227bfb] 第二次
 1 file changed, 6 insertions(+)
 create mode 100644 test.java
[root@13git yy000]# git log
commit c227bfbaf87ad3296ca013033afa37ffd44c81ce
Author: shisi <mm@shisi.com>
Date:   Thu Jul 25 10:50:13 2024 +0800

    第二次

git%E6%93%8D%E4%BD%9C%E9%83%BD%E5%BA%94%E8%AF%A5%E5%B7%A5%E4%BD%9C%E5%9C%A8%EF%BC%8C%E6%8C%87%E5%AE%9A%E7%9A%84init%20%E7%9B%AE%E5%BD%95%E4%B8%8B%E8%BF%9B%E8%A1%8C%EF%BC%89">2.创建分支,跳转分支(所有的git操作都应该工作在,指定的init 目录下进行)

[root@13git yy000]# git branch abranch
[root@13git yy000]# git branch 
  abranch
* master
[root@13git yy000]# git checkout abranch 
切换到分支 'abranch'
[root@13git yy000]# git branch 
* abranch
  master
[root@13git yy000]# ls
test.java
[root@13git yy000]# echo "我是a" >> test.java 
[root@13git yy000]# cat test.java 
public class Test{
        public static void main(String [] args){
                System.out.println("hello world");
        }
}
你好世界
你好yulan
我是a
[root@13git yy000]# git add .
[root@13git yy000]# git commit -m "a"
[abranch f0c0fa6] a
 1 file changed, 1 insertion(+)
[root@13git yy000]# git checkout master 
切换到分支 'master'
[root@13git yy000]# git branch 
  abranch
* master
[root@13git yy000]# cat test.java 
public class Test{
        public static void main(String [] args){
                System.out.println("hello world");
        }
}
你好世界
你好yulan
[root@13git yy000]# git checkout abranch 
切换到分支 'abranch'
[root@13git yy000]# cat test.java 
public class Test{
        public static void main(String [] args){
                System.out.println("hello world");
        }
}
你好世界
你好yulan
我是a
[root@13git yy000]# 

1.分支共享(不提交)

[root@13git yy000]# git checkout -b bbranch
切换到一个新分支 'bbranch'
[root@13git yy000]# git branch 
  abranch
* bbranch
  master
[root@13git yy000]# echo "我是b" >> test.java 
[root@13git yy000]# git checkout abranch 
M    test.java
切换到分支 'abranch'
[root@13git yy000]# cat test.java 
public class Test{
        public static void main(String [] args){
                System.out.println("hello world");
        }
}
你好世界
你好yulan
我是a
我是b
[root@13git yy000]# 

2.合并,先切换到主分支

[root@13git yy000]# git checkout master 
切换到分支 'master'
[root@13git yy000]# git branch 
  abranch
  bbranch
  cbranch
* master
[root@13git yy000]# git merge abranch 
更新 7908685..cf43e5e
Fast-forward
 test.java | 2 ++
 1 file changed, 2 insertions(+)
[root@13git yy000]# git log
commit cf43e5ee9e1e32a9640689fbc1bd1762c4c60fff
Author: shisi <mm@shisi.com>
Date:   Thu Jul 25 14:09:56 2024 +0800

    aaa

commit f0c0fa6f64d7e7a781dadb99fc906fdb15db79fb
Author: shisi <mm@shisi.com>
Date:   Thu Jul 25 11:35:41 2024 +0800

    a

commit 790868543cdbe9d2e68f4da9dc40ec8983464d0c
Author: shisi <mm@shisi.com>
Date:   Thu Jul 25 11:10:58 2024 +0800

    第三次提交

commit c227bfbaf87ad3296ca013033afa37ffd44c81ce
Author: shisi <mm@shisi.com>
Date:   Thu Jul 25 10:50:13 2024 +0800

    第二次
[root@13git yy000]# 

3.删除分支

[root@13git yy000]# git branch -d abranch 
已删除分支 abranch(曾为 cf43e5e)。
[root@13git yy000]# git branch -d bbranch 
已删除分支 bbranch(曾为 f0c0fa6)。
[root@13git yy000]# git branch -d cbranch  
已删除分支 cbranch(曾为 6acdae4)。

[root@13git yy000]# git branch 
* master

4.创造分支合并冲突

[root@13git yy000]# echo "我是主分支,我修改了文件" > test.java 
[root@13git yy000]# git checkout -b newbtanch
M    test.java
切换到一个新分支 'newbtanch'
[root@13git yy000]# git branch 
  master
* newbtanch
[root@13git yy000]# cat test.java 
我是主分支,我修改了文件
[root@13git yy000]# echo "我是玉兰,我要吃烤鸭" >> test.java 
[root@13git yy000]# cat test.java 
我是主分支,我修改了文件
我是玉兰,我要吃烤鸭
[root@13git yy000]# git checkout master 
M    test.java
切换到分支 'master'
[root@13git yy000]# cat test.java 
我是主分支,我修改了文件
我是玉兰,我要吃烤鸭
[root@13git yy000]# git checkout newbtanch 
M    test.java
切换到分支 'newbtanch'
[root@13git yy000]# git status 
# 位于分支 newbtanch
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      test.java
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@13git yy000]# git add .
[root@13git yy000]# git commit -m "abcd"
[newbtanch db7438b] abcd
 1 file changed, 2 insertions(+), 9 deletions(-)
[root@13git yy000]# git checkout master 
切换到分支 'master'
[root@13git yy000]# cat test.java 
public class Test{
        public static void main(String [] args){
                System.out.println("hello world");
        }
}
你好世界
你好yulan
我是a
我是b
[root@13git yy000]# echo "efg"
efg
[root@13git yy000]# echo "efg" >> test.java 
[root@13git yy000]# git add .
[root@13git yy000]# git commit -m "注释说明"
[master b004f5f] 注释说明
 1 file changed, 1 insertion(+)

5.主分支和newbranch都有修改,并进行合并

[root@13git yy000]# git branch 
* master
  newbtanch
[root@13git yy000]# git merge newbtanch 
自动合并 test.java
冲突(内容):合并冲突于 test.java
自动合并失败,修正冲突然后提交修正的结果。
[root@13git yy000]# 

6.解决冲突:

[root@13git yy000]# vim test.java         //进入文件后手动删除(dd)

[root@13git yy000]# git add .
[root@13git yy000]# git commit -m "合并"
[master c2b71d6] 合并
[root@13git yy000]# git log

git%E6%8B%89%E5%8F%96">3.git拉取

git">        1.在客户端cli主机,安装git

        [root@16cli ~]# yum -y install git

git%E4%B8%BB%E6%9C%BA%EF%BC%9A">        2.免密链接git主机:

        [root@16cli ~]# yum -y install openssh

        [root@16cli ~]# yum -y install pwgen

        [root@16cli ~]# ssh-keygen

        [root@16cli ~]# ssh-copy-id root@192.168.2.13

        [root@16cli ~]# ssh 192.168.2.13
        Last login: Thu Jul 25 13:20:24 2024 from 192.168.2.2
        [root@13git ~]# exit
        登出
        Connection to 192.168.2.13 closed.
        [root@16cli ~]# 

git%E4%B8%BB%E6%9C%BA%E4%B8%AD%E7%9A%84yy000%E7%9B%AE%E5%BD%95">        3.克隆git主机中的yy000目录

        [root@16cli ~]# git clone 192.168.2.13:/yy000/.git/
        正克隆到 'yy000'...
        remote: Counting objects: 22, done.
        remote: Compressing objects: 100% (17/17), done.
        remote: Total 22 (delta 4), reused 0 (delta 0)
        接收对象中: 100% (22/22), done.
        处理 delta 中: 100% (4/4), done.
        [root@16cli ~]# ls

        4.检查:

        [root@16cli ~]# cd yy000/
        [root@16cli yy000]# ls
        efg  test.java
        [root@16cli yy000]# ls -a
        .  ..  efg  .git  test.java
        [root@16cli yy000]# 

        5.修改内容,设置自己的账号和邮箱

        [root@16cli yy000]# git config --global user.name aaa
        [root@16cli yy000]# git config --global user.email aaa@163.com
        [root@16cli yy000]# touch A.class

        [root@16cli yy000]# git config --global push.default matching
        [root@16cli yy000]# git push
        Everything up-to-date

        [root@16cli yy000]# git pull
        来自 192.168.2.13:/yy000/
         * [新分支]          zzz        -> origin/zzz
        Already up-to-date.

4.在码云上创建项目,进行pull 和 push:

1.初始化目录:

2.回到cli客户端,克隆项目中内容

[root@16cli yy000]# git clone https://gitee.com/shisim/yulan.git
正克隆到 'yulan'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
[root@16cli yy000]# 

3.创建文件:

[root@16cli yy000]# cd yulan/
[root@16cli yulan]# ls
README.en.md  README.md
[root@16cli yulan]# mkdir -p src/main/java/
[root@16cli yulan]# ls
README.en.md  README.md  src
[root@16cli yulan]# touch src/main/java/test.java
[root@16cli yulan]# tree src/
src/
└── main
    └── java
        └── test.java

2 directories, 1 file
[root@16cli yulan]# 

4.提交:

[root@16cli yulan]# git add .
[root@16cli yulan]# git commit -m "这个是文件提交"

5.在码云上实现:

6.编辑文件内容:

[root@16cli yulan]# vim src/main/java/test.java 
[root@16cli yulan]# git add .
[root@16cli yulan]# git commit -m "修改Java文件"

7.在码云页面查看:

5.克隆码云上任意项目:

[root@16cli yulan]# cd ..
[root@16cli yy000]# git clone https://gitee.com/nsdvn/nsdvn2302
正克隆到 'nsdvn2302'...
remote: Enumerating objects: 1976, done.
remote: Total 1976 (delta 0), reused 0 (delta 0), pack-reused 1976
接收对象中: 100% (1976/1976), 177.38 MiB | 2.15 MiB/s, done.
处理 delta 中: 100% (1038/1038), done.
[root@16cli yy000]# 


http://www.ppmy.cn/news/1501879.html

相关文章

javascript(二)

三、选择器 1.选择器的种类 document.getElementById() 通过id来查找元素 document.getElementsByTagName() 通过标签来查找元素 document.getElementsByClassName() 通过类名&#xff08;class&#xff09;来查找元素 document.getElementsByName() 通过name来查找元…

Sonatype Nexus Repository搭建与使用(详细教程3.70.1)

目录 一. 环境准备 二. 安装jdk 三. 搭建Nexus存储库 四. 使用介绍 一. 环境准备 主机名IP系统软件版本配置信息nexus192.168.226.26Rocky_linux9.4 Nexus Repository 3.70.1 MySQL8.0 jdk-11.0.23 2核2G&#xff0c;磁盘20G 进行时间同步&#xff0c;关闭防火墙和selinux…

学习笔记-系统框图传递函数公式推导

目录 *待了解 现代控制理论和自动控制理论区别 自动控制系统的组成 信号流图 1、系统框图 1.1、信号线、分支点、相加点 1.2、系统各环节间的连接 1.3、 相加点和分支点的等效移动&#xff08;比较点、引出点&#xff09; 2、反馈连接公式推导 2.1、前向通路传递函数…

旷野之间32 - OpenAI 拉开了人工智能竞赛的序幕,而Meta 将会赢得胜利

他们通过故事做到了这一点&#xff08;Snapchat 是第一个&#xff09;他们用 Reels 实现了这个功能&#xff08;TikTok 是第一个实现这个功能的&#xff09;他们正在利用人工智能来实现这一点。 在人工智能竞赛开始时&#xff0c;Meta 的人工智能平台的表现并没有什么特别值得…

类和对象的深入了解4

1.析构函数 1.1析构函数概念 与构造函数功能相反&#xff0c;析构函数不是完成对对象本身的销毁&#xff0c;局部对象销毁工作是由编译器完成 的。而对象在销毁时会自动调用析构函数&#xff0c;完成对象中资源的清理工作。它的名字与类名相同&#xff0c;前面加上一个波浪号…

C#高级:数据库中使用SQL作分组处理3(ROW_NUMBER() 关键字)

一、分组后找出指定序号的数据 【需求】查出每个班级第三个注册入学的学生信息 【表和字段】Student: ID Class Name Registrationtime 【实现SQL】 WITH RankedStudents AS (SELECT ID,Class,Name,Registrationtime,ROW_NUMBER() OVER(PARTITION BY Class ORDER BY Registra…

python机器学习12--Regression回归分析

1.数据准备 第一步&#xff1a;数据内容一定要有以下两种值域的因果数据。 特征&#xff08;Feature&#xff09;&#xff1a;因&#xff0c;在统计学称为自变量&#xff08;Independent Variable&#xff09;。 标签答案&#xff08;Label&#xff09;&#xff1a;果&a…

04-用户画像+sqoop使用

优点 sqoop的作用是实现数据的导入和导出&#xff0c;主要是对数据库和数据仓库之间的操作 只要是支持jdbc连接的数据库都可以使用sqoop操作 添加Sqoop到环境变量中 export SQOOP_HOME/export/server/sqoop export PATH$PATH:$SQOOP_HOME/bin:$SQOOP_HOME/sbinsource /etc/…