可以做軟件的網(wǎng)站有哪些中文域名注冊管理中心
Git安裝
1.安裝git
2.創(chuàng)建git倉庫
3.創(chuàng)建文件并且提交文件? (git add? . 將文件提交到緩存)(git? commit -m? 說明)(git log? 查看歷史)
4.分支創(chuàng)建與解決分支沖突問題
? ? ? ? 創(chuàng)建主機(jī)(git? 192.168.1.26)
????????(1)[root@git ~]# yum -y install git
下圖是安裝成功
????????(2)[root@git ~]# mkdir /yy000? ?//存放git文件
使用git指令,一定要cd 到初始化最后的目錄中
[root@git ~]# cd /yy000
[root@git yy000]#?
[root@git yy000]# git init? ?//相當(dāng)于建立一個工作區(qū)
初始化空的 Git 版本庫于 /yy000/.git/有隱藏文件
????????(3)[root@git yy000]# vim Test.java
public?class?Test{
????????public?static?void?main(String?[]?args){
????????????????System.out.println("hello?world");
????????}
}
[root@git yy000]# git config --global user.name liyang
[root@git yy000]# git config --global user.email 2870541506@163.com
[root@git yy000]# echo "//這是一行java注釋,不會被編譯,能提交文件的可讀性" > Test.java?
[root@git yy000]# cat Test.java?
//這是一行java注釋,不會被編譯,能提交文件的可讀性
分支的應(yīng)用
[root@git yy000]# git log? ?(查看歷史提交記錄)
[root@git yy000]# git branch? ?(倉庫當(dāng)前倉庫的分支)
* master? ? ? ? ? ? (當(dāng)前只有一個master分支,這個分支叫主分支,最后所有分支會合到master主分支)
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋?[root@git yy000]# git branch abranch? ?(切換分支)
[root@git yy000]# git branch
? abranch
* master
[root@git yy000]# #切換到a的分支上?
[root@git yy000]# git checkout abranch
切換到分支 'abranch'
[root@git yy000]# git branch
* abranch
? master
[root@git yy000]# cat Test.java?
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋
[root@git yy000]# echo "//我是a員工,我不驕傲" >> Test.java?
[root@git yy000]# cat Test.java? ? (a分支可以看到)
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋
//我是a員工,我不驕傲
[root@git yy000]# git add .
[root@git yy000]# git commit -m "a員工提交的內(nèi)容"
[abranch ba33d65] a員工提交的內(nèi)容
?
在(創(chuàng)建b分支,在b上創(chuàng)建內(nèi)容a分支可以看到)
[root@git yy000]# git branch
* abranch
? master
[root@git yy000]# git checkout -b bbranch? 跳轉(zhuǎn)的時候創(chuàng)建分支
切換到一個新分支 'bbranch'
[root@git yy000]# git branch
? abranch
* bbranch
? master
[root@git yy000]# cat Test.java?
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋
//我是a員工,我不驕傲
[root@git yy000]# echo "我是b員工" >> Test.java?
[root@git yy000]# git branch
? abranch
* bbranch
? master
[root@git yy000]# git checkout abranch? ? 切換分支
M?? ?Test.java
切換到分支 'abranch'
[root@git yy000]# cat Test.java?
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋
//我是a員工,我不驕傲
我是b員工[root@git yy000]# git branch cbranch??創(chuàng)建分支
[root@git yy000]# mkdir abc
[root@git yy000]# touch efg
[root@git yy000]# ls
abc ?efg ?Test.java
[root@git yy000]# git add abc/
[root@git yy000]# gitcommit -m "更新一個目錄"
-bash: gitcommit: 未找到命令
[root@git yy000]# git commit -m "更新一個目錄"
# 位于分支 master
# 未跟蹤的文件:
# ? (使用 "git add <file>..." 以包含要提交的內(nèi)容)
#
#?? ?efg
提交為空,但是存在尚未跟蹤的文件(使用 "git add" 建立跟蹤)
[root@git yy000]# git add efg
[root@git yy000]# git commit -m "新增了一個efg文件"
[master 82926d5] 新增了一個efg文件
?1 file changed, 0 insertions(+), 0 deletions(-)
?create mode 100644 efg
[root@git yy000]# git add .
[root@git yy000]# git commit -m "所有的文件都提交"
# 位于分支 master
無文件要提交,干凈的工作區(qū)
分支的創(chuàng)建
?[root@git yy000]# git branch
? abranch
? bbranch
? cbranch
* master[root@git yy000]# git merge abranch
?沒有什么理由,我就是要合并
[root@git yy000]# git log
分支的刪除?
[root@git yy000]# git branch -d abranch
已刪除分支 abranch(曾為 2c99666)。
[root@git yy000]# git branch -d bbranch
已刪除分支 bbranch(曾為 ba33d65)。
[root@git yy000]# git branch -d cbranch
已刪除分支 cbranch(曾為 1b9eaa5)。
[root@git yy000]# git branch
* master
[root@git yy000]# cat Test.java?
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋
//我是a員工,我不驕傲
我是b員工
合并時有可能會出現(xiàn)文件沖突:比如:主分支修改了這個文件,zhangsan也修改了這個文件
兩個分支都發(fā)生了改變,合并的時候就會出現(xiàn)沖突
[root@git yy000]# git branch
* master
[root@git yy000]# echo "//我是主分支,我修改了文件0" > Test.java?
[root@git yy000]# git checkout -b newbranch
M?? ?Test.java
切換到一個新分支 'newbranch'
[root@git yy000]# git branch
? master
* newbranch
[root@git yy000]# cat Test.java?
//我是主分支,我修改了文件0
[root@git yy000]# echo "//我是newbranch分支" >> Test.java?
[root@git yy000]# cat Test.java?
//我是主分支,我修改了文件0
//我是newbranch分支
[root@git yy000]# git checkout master
M?? ?Test.java
切換到分支 'master'
[root@git yy000]# cat Test.java?
//我是主分支,我修改了文件0
//我是newbranch分支
[root@git yy000]# git checkout newbranch
M?? ?Test.java
切換到分支 'newbranch'
[root@git yy000]# git status
# 位于分支 newbranch
# 尚未暫存以備提交的變更:
# ? (使用 "git add <file>..." 更新要提交的內(nèi)容)
# ? (使用 "git checkout -- <file>..." 丟棄工作區(qū)的改動)
#
#?? ?修改: ? ? ?Test.java
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@git yy000]# git add .
[root@git yy000]# git commit -m "abcd"
[newbranch 838d01d] abcd
?1 file changed, 2 insertions(+), 5 deletions(-)
[root@git yy000]# git checkout master
切換到分支 'master'
[root@git yy000]# cat Test.java?
//這是一行java注釋,不會被編譯,能提交文件的可讀性
//我又加了一個注釋
//我又加了一個ABBABBBABABB注釋
//我是a員工,我不驕傲
我是b員工
[root@git yy000]# echo "eft"
eft
[root@git yy000]# git add .
[root@git yy000]# git commit -m "ccc"
# 位于分支 master
無文件要提交,干凈的工作區(qū)
[root@git yy000]# echo "fsddsgsFSGSSFF" > Test.java?
[root@git yy000]# git add .
[root@git yy000]# git commit -m "dadadadadad"
[master 1a56c36] dadadadadad
?1 file changed, 1 insertion(+), 5 deletions(-)
[root@git yy000]# #主分支有修改,newbranch也有修改
[root@git yy000]# #現(xiàn)在要將newbranch合并到主分支
[root@git yy000]# git branch
* master
? newbranch
[root@git yy000]# git merge newbranch
自動合并 Test.java
沖突(內(nèi)容):合并沖突于 Test.java
自動合并失敗,修正沖突然后提交修正的結(jié)果。
以上創(chuàng)造了一個沖突解決沖突
[root@git yy000]# cat Test.java?
<<<<<<< HEAD
fsddsgsFSGSSFF
=======
//我是主分支,我修改了文件0
//我是newbranch分支
>>>>>>> newbranch
[root@git yy000]# vim Test.java?
?
?Git拉去
新建主機(jī)(zhangsan? 192.168.1.27? ?)
安裝git
[root@localhost ~]# ?yum -y install git
做免密登錄
[root@localhost yy000]# git pull
Already up-to-date.
[root@localhost yy000]# #修改內(nèi)容
[root@localhost yy000]# #設(shè)置自己的姓名和郵箱
[root@localhost yy000]# git config --global user.name aaa
[root@localhost yy000]# git config --global user.email aaa@163.com
[root@localhost yy000]# #修改內(nèi)容
[root@localhost yy000]# touch A.class
[root@localhost yy000]# git add .
[root@localhost yy000]# git commit -m "aaaaa"
[master 392138f] aaaaa
[root@localhost yy000]# #第一次使用對方的項目 ? git clone
[root@localhost yy000]# #獲取更新 就用git ?pull
[root@localhost yy000]# #git clone 會在當(dāng)前目錄下創(chuàng)建新的倉庫
?
在碼云上面創(chuàng)建項目并且pull和push
Gitee - 基于 Git 的代碼托管和研發(fā)協(xié)作平臺?(網(wǎng)址)
點(diǎn)擊初始化
[root@localhost yy000]# git clone https://gitee.com/effective-maple-leaf-c/laoli.git
(復(fù)制自己的網(wǎng)址)
[root@localhost yy000]# ls
A.class ?efg ?laoli ?Test.java
[root@localhost yy000]# cd laoli/
[root@localhost laoli]# mkdir -p src/main/java
[root@localhost laoli]# ls
README.en.md ?README.md ?src
[root@localhost laoli]# touch src/main/java/Test.java
[root@localhost laoli]# git commit -m "文件提交"
[root@localhost laoli]# git push
Username for 'https://gitee.com': 13269546219? ?(輸入網(wǎng)站的賬戶)
Password for 'https://13269546219@gitee.com':? ?(輸入網(wǎng)站的密碼)
Counting objects: 7, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 429 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 2846f492
To https://gitee.com/effective-maple-leaf-c/laoli.git
? ?a8899d3..520fd68 ?master -> master