目录
[1.Git 分布式版本控制系统:](#1.Git 分布式版本控制系统:)
[2.创建分支,跳转分支(所有的git操作都应该工作在,指定的init 目录下进行)](#2.创建分支,跳转分支(所有的git操作都应该工作在,指定的init 目录下进行))
[4.在码云上创建项目,进行pull 和 push:](#4.在码云上创建项目,进行pull 和 push:)
1.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 [email protected] \[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 \
Date: Thu Jul 25 10:50:13 2024 +0800 第二次
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 \
Date: Thu Jul 25 14:09:56 2024 +0800 aaa commit f0c0fa6f64d7e7a781dadb99fc906fdb15db79fb Author: shisi \ Date: Thu Jul 25 11:35:41 2024 +0800 a commit 790868543cdbe9d2e68f4da9dc40ec8983464d0c Author: shisi \ Date: Thu Jul 25 11:10:58 2024 +0800 第三次提交 commit c227bfbaf87ad3296ca013033afa37ffd44c81ce Author: shisi \ 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 \