Deployment and application of gitlab

Preparing the environment:

Three machines, one to do the client (to upload the code by the programmer) 192.168.1.10, do a git server 192.168.1.20, a doing jenkins 192.168.1.30

git: distributed software version control system used independently,

1. Installation: yum -y install git

2. Configure basic information

git config --global user.name "Mr Zhao" Configuring User Name

git config --global userr.email "[email protected]" Configuration Mailbox

git config --global core.editor vim configuration editor

3. Review the information

git config --list

Configuring the cat ~ / .gitconfig file is located, above the basic information can be modified

4. git important area of ​​work

Workspace: preparation of the directory code

Temporary Area: .git / index, a buffer zone between the workspace and repository, allowing users to regret region

Repository: Workspace have a .git directory, this is the repository

Workspace --git add -> staging area -> git commit -> Repository

5. Create warehouse

Method One: Create a project to create the beginning

git init mygit   

Initialize an empty Git repository in /root/mygit/.git/

The second method to create the repository in an existing project in

mkdir myweb

cd myweb

echo "hello linux" > index.html

git init

Initialize an empty Git repository in /root/myweb/.git/

ls -A

.git  index.html

[root @ Client myweb] # git Status -s
A index.html
?? hosts
[root @ Client myweb] # git the Add. # submit all files to the staging area
[root @ Client myweb] # git Status -s
A hosts
A index.html


Withdrawal hosts from scratch

[root @ Client myweb] # git RM --cached hosts
RM 'hosts'
[root @ Client myweb] # git Status -s withdraw view becomes a ??
A index.html
?? hosts

Creating .gitignore ignore what is not added to the repository file hosts

[root@client myweb]# echo hosts >> .gitignore

[root@client myweb]# echo .gitignore >> .gitignore
[root@client myweb]# cat .gitignore
hosts

.gitignore
[root @ Client myweb] # git Status -s
A index.html
6. version submitted to the warehouse

git commit # direct knock appear vim editor to write the log ,, If the log is blank, terminate submit, that is the definition of core vim as defined above

git commit -m "init data"

[root @ Client myweb] # git the commit -m "the init the Data"
[Master (root submit) a8474aa] the init the Data
 1 File changed, 1 Insertion (+)
 the Create the MODE 100644 index.htmlecho hosts >> .gitignore
[root @ Client myweb ] # git Status
# master branch located
no documents to be submitted, a clean workspace
7. deleted files and restore workspace:

[root @ Client myweb] # RM -rf index.html
[root @ Client myweb] # git Status
# located at the branch Master
# has not changed for submission to the staging:
# (use "git add / rm <file> ... "updates to be submitted)
# (use" git checkout - <file> ... " to discard changes in working area)
#
# deleted: index.html
#
revise added yet submitted (using the" git add "and / or" git commit -a ")

8. recover deleted index.html

[root @ Client myweb] # git Checkout - index.html
[root @ Client myweb] # LS
hosts index.html
9. delete files from the repository

[root@client myweb]# git ls-files
hosts1
index.html
[root@client myweb]# git rm hosts1
rm 'hosts1'
[root@client myweb]# git ls-files
index.html

[root @ Client myweb] # git Status
# located at the branch master
changes to be submitted #:
# (use "git reset HEAD <file> ... " to withdraw staging area)
#
# deleted: hosts1
#
10. completely remove ( no regret medicine)

[root @ Client myweb] # git the commit -m "RM hosts1"
[master 9,898,403] RM hosts1
 1 File changed, 1 Deletion (-)
 the Delete the MODE 100644 hosts1
[root @ Client myweb] # git Status
# master branch located
no documents to submit, clean work area
11. recover accidentally deleted files (through the repository to restore to get it back)

[root@client myweb]# git log
commit 98984031e3d15efe9d77ed81a9f8c6aaa40c7ed3
Author: Mr.Zhao <[email protected]>
Date:   Mon Nov 18 11:52:21 2019 +0800



commit aedf50f5a42a93aa930d6888946e4aa8b3fff863
Author: Mr.Zhao <[email protected]>
Date:   Mon Nov 18 11:49:39 2019 +0800


[root@client myweb]# git checkout aedf50f5a42a93aa930d6888946e4aa8b3fff863
Note: checking out 'aedf50f5a42a93aa930d6888946e4aa8b3fff863'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD 目前位于 aedf50f... hosts1
[root@client myweb]# ls
hosts1  index.html

git tag tag

flag may be set to analog tag once

As will submit a first set of software version number

[Client MyWeb the root @] Git Tag # 2.0
[Client MyWeb the root @] Git Tag #
1.0
2.0
Git branch

git

[root @ Client myweb] # git the Add.
[root @ Client myweb] # git the commit -m "the Add passwd"
# head pointer isolated from a8474aa
no documents to be submitted, a clean work area
[root @ Client myweb] # LS
the Hello index the passwd .html
[the root @ Client MyWeb] # B1 Git Checkout
handover branch to 'B1'
[the root @ Client MyWeb] LS #
Hello index.html the passwd
[the root @ Client MyWeb] # B1 Git Checkout
handover branch to 'B1'
[the root MyWeb @client] LS #
Hello index.html the passwd
[the root @ Client MyWeb] Master # git Checkout
handover branch to 'Master'
[the root @ Client MyWeb] LS #
index.html
[the root @ Client MyWeb] View branch # git branch
git See branch branches
[the root @ Client MyWeb] # Git the passwd RM
RM 'the passwd'
[root@client myweb]# git commit -m *
[Master aecac25] *
 5 Files changed, 24-deletions (-)
 the Delete the MODE 100644 a.txt
 the Delete the MODE 100644 the Hello
 the Delete the MODE 100644 hi.txt
 the Delete the MODE 100644 index.html
 the Delete the MODE 100644 passwd
[root @ Client myweb] # git Status
# master branch located
no documents to be submitted, a clean work area


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/luwei0915/p/11882057.html