Mac OS use SSH to build git server server detailed tutorials, and git basic usage

Source: Internet
Author: User
Tags git clone

Learn more about Mac-connected git operations for Mac

First on the service side

First: Create a new warehouse

1, Cd/users/username/projects

Use the Linux command to enter a folder that you want to create to share with others.

2,sudo git--bare init

Build a git repository.

The "git init–bare" method creates a so-called bare repository, which is called a bare repository because the repository only stores the version information submitted by Git history, and does not allow the user to perform various git operations on it, and if you do, you will only get the following error (" This operation must is run in a work Tree")

3, give permission to the folder where the Git repository is located recursively

Cd.. && sudo chmod-r 777 projects

4, because Git does not allow others to push to the local repository by default. So you give permission to allow others to push.

Steps are as follows

(1) cd/users/username/projects

Enter the local warehouse

(2) sudo vim. git/config

If you build a repository with GIT init

sudo vim config

If you use git init--bare to build a warehouse

Use VIM to open the Git configuration file.

Here's a little tutorial about vim. Vim is a powerful editor with some quick methods that will soon complete the task you give it

Vim Operation Tutorial

After entering vim, if you have not pressed any other keys on the keyboard. You can press Shift+g on your keyboard first, and you'll move the cursor to the last line of text. )

Click the O key; (insert a row below the current line and enter the input mode)

~, add

[Receive]
Denycurrentbranch = Ignore

On the client

1,CD Gittest

Go to the repository where you want to store your git files.

2,sudo git clone [email protected]:/path/server_project_name/path/local_project_name

sudo: To run with administrator privileges.

git clone: Copy a git repository from the remote.

[Email protected]: name is the username of the server and then +@+ the IP address of the server

: Server_project_name local_project_name: The path to the server git file and the local git repository path and name

3,CD Local_project_name (the Git local git repository name you just started)

Go to your git file.

6, you can try to add something to the Git repository. Test1,test2 Two identical files are added here

7. Enter GIT status to view local changes

untracked files The following file is a file that has not been submitted.

8,sudo git add test1

Tell Git that you know that the "test1" file was added in new. The add command indicates that a new file has been "added" or "original" has been "modified" by the commit confirmation.

9,git status (view current status)

Changes to be committed:

The following is the file you have submitted.

untracked files:

Here are the files you haven't submitted yet.

10,sudo git Add.

Of course, a lot of documents you can not be such a submission of the strips. Git gives me a lot of ways. If you are sure that all files can be submitted then you will use "sudo git Add." To add all.

Git also provides several ways to add files as required, as follows

Http://imtx.me/archives/1297.html

One, sudo git commit-m ' Add 2 files '

Then confirm that all content is formally submitted.

-M followed by an annotation at the time of submission. This better be more detailed about the better. After the mistake can come back to see which developer's mistake, as well as his modified ideas.

sudo git pull Origin master

Then, before committing to the server, we need to pull the warehouse code from the server to local comparison. There is no conflict (different developers modify the same file as a conflict)

Conflict resolution refer to Links

http://blog.csdn.net/u012150179/article/details/14047183

If the following error is reported:

FATAL:COULDN ' t find remote ref Master
Fatal:the remote end hung up unexpectedly

Because no one has submitted the code, the first time you have to directly push the code up.

13,sudo git push Origin master

Put the final code in the warehouse and replace the code inside the warehouse.

Reprint: http://blog.csdn.net/liuyuyefz/article/details/17025905

Mac OS use SSH to build git server server detailed tutorials, and git basic usage

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.