Aquaboutic | Focus Security Research | Vulnerability Exploit | POC

Home

git server building and basic operation of git

Posted by deeson at 2020-02-26
all

In the past two days, we have built git server and struggled for a long time to share some of our tangled records.

"Git server setup"

1. For git installation, check whether the following has been installed before installation:

If not installed:

2. select a folder to initialize the Git warehouse:

Here -- bare means to build a bare warehouse, where add and commit operations cannot be performed. The initial code in the server also needs to be pushed in by the client. You cannot commit by yourself. I really have been struggling with this problem for a long time. At first, I switched to test.git, then git init, and then the later operations were all wrong. In fact, initialization is OK.

3. Create a new user to run git service (any user here can, just find the group that the user is in, and the user name will be used in SSH login later)

git

At this time, test.git belongs to root: root:

We changed it to zita: zita:

At this time, the GIT server is set up. It's just hot and easy. There's no other operation...

『Git Client』

The client here is built on windows. Don't ask me why I want to use windows, because of the above requirements.

After installing git GUI on windows, you can start to operate.

1. Create a new folder as git warehouse, where Git is initialized.

After initialization, a hidden directory of. Git will be generated automatically. Do not modify this folder manually.

2. Basic configuration:

Right click to open "git GUI" for basic configuration:

1) Configure the user name and mailbox number. This step is only to identify different users.

Fill in and save.

2) Generate SSH key for remote login.

 

Then log in to the GIT server and add SSH key to the / home / git /. SSH / authorized_. If you do not have this file, please follow this path to create a new file.

/home/git/.ssh/authorized_keys文件中。如果没有此文件,请按照这个路径新建文件。

3. Basic operation:

1) To add and submit files, I added a file in the version Library:

Replace "git bash":

You can see that "1.txt" has changed

 

Check the version library status again, no update:

2) Version fallback:

I first modify the document several times, and then submit it several times:

At this point, I want to go back to the first commit:

3) Back to the future:

Now I want to go back to second commit. What should I do?

At this time, there is only one record left in Git log:

We can use git reflog to find the version number:

4. Remote operation:

1) Clone remote library:

There is nothing in the version library at this time, so it is empty.

2) Push code up:

To view the remote host name:

If not, you can add. Here, "origin" is the name of the customized remote server, zita is the user name just added, 192.168.1.140 is the IP address of GIT server, and / home / githome / test.git is the GIT warehouse folder just set:

To view the local branch, the default is master:

Push code to remote server:

Push succeeded. At this time, I can't see the code I push on the server, but others can see it on his client side.

3) At this time, I will create another folder, initialize a new warehouse, and add a remote server:

At this time, the file is still in a buffer. We need to merge it to our own branch:

First look at the remote branch name:

I merge the remote origin / Master branch into my master branch:

Get the file locally:

Summary

Git also has a lot of operations and some principles. Let's learn when we use it.

reference material:

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

http://www.csdn.net/article/2014-06-17/2820265-git