Detailed explanation of Git under Ubuntu from construction to use

Detailed explanation of Git under Ubuntu from construction to use

First, the construction of git

(1)sudo apt-get update

(2)sudo apt-get -y install git

(3) , git --version (check the version number of git )

(4) , you can install the git client on the windows client

Download Git for Windows , address: https://git-for-windows.github.io/

 

(5) , enter the home directory on the server side

(6) , cd / home

(7) , add git user and change the password

(8)sudo useradd git

(9)sudo passwd git

(10) , create a code warehouse

mkdir -p data/git/gittest.git

(11) , initialize the warehouse

git init --bare data/git/gittest.git

(12) , enter the warehouse

cd data/git/

(13) , modify the warehouse owner

chown -R git:git gittest.git/

 

 

Second, in the winnddows client operation

run client software

 

Note: First create a file named wamp64 under a drive letter

      Below this file write create a file called www (optional)

 

Then do the following in the client software:

1)、dee@Lenovo-PC MINGW64 /d

$ cd wamp64/www

 

dee@Lenovo-PC MINGW64 /d/wamp64/www

$ mkdir gittest_gitbash

 

dee@Lenovo-PC MINGW64 /d/wamp64/www

$ cd gittest_gitbash

 

dee@Lenovo-PC MINGW64 /d/wamp64/www/gittest_gitbash

$

(2) Then the client clones the code file from the git server

$ git clone [email protected]:/home/data/gittest.git

(3) If it is not port 22 , we can adjust it like this

$ git clone ssh://[email protected]:7700/home/data/gittest.git

 

When synchronizing, a box may pop up asking you to choose YES/NO , of course, choose yes . After the update, start playing.

 

Playing git , of course, the operation command is the most important thing.

After the editor's hard work, I finally came up with a set of git command operation solutions. Let's stop talking nonsense and go directly to the dry goods, all of which will be contributed to everyone.

(1) , I believe that everyone has entered the operation directory of the client above.

The first step is to initialize the working directory.

Git init

The second part, create a user, this step cannot be forgotten. After all, you will use this user to submit code later.

Git config user.name “shengyang”

Git config user.email”[email protected]

The third part, add a file named test.txt

git add test.txt

Git status (this is the command to view git status)

The fourth step is to submit the files in the workspace to the cache area.

Git commit -m”shegyang”

The fifth part, finally, is to push the modified code to the git server.

Git push test.txt

 

3. Of course, the focus is always on the back. How do we restore this is the key point. The editor has never played this thing before, so it took a long time to restore it. Now I wrote a special article for this to summarize.

 

Yes, those methods on the Internet are all used, and they are all copied one by one; brother, this set is economical.

example:

Created a file 111.txt in the working directory , the content is 111

Then: git add 111.txt

      Git commit -m”shengyang”

      Git log 111.txt ( see the commit log for 111.txt )

 

I saw a submission record, yes, that string of id is the id number of the version you will reply to in the future .

Next we continue vim 111.txt

Add content, modify content. Then add , commit , push . Then git log 111.txt

 

wonderful, wonderful

Now, you have to revert to the previous version number, or the content. What do you say on the Internet, reset , etc. A lot of things, the editor tried them one by one, and it didn't work, and finally summed up a set.

 

1. git status    to see the status

 

nothing, right?

2. Just add or modify the content of vim 111.txt directly , save and exit

3. Then git checkout id file name (get it), you can use cat 111.txt to take a look.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324593542&siteId=291194637