Common use of Mac git

Source: Internet
Author: User
Tags using git git clone

One. Check git

Before using git, check to see if the Git,mac installed on this machine is installed by default on Git.

1. Open the terminal, enter the instructions, if you have installed Git will show the version number

git version

2. If git is not already installed, you can use Xcode command line tools and install git using the following commands

xcode-Select --install

Two. Create a new project and upload

1. Create a new remote repository on a remote third-party hosting site (Github, code cloud, etc.)

2. Create a new project locally, take Xcode iOS as an example, when you create a new project, be aware of whether a . git git file is being uploaded as a new project and you need to delete the file first

3. Open the terminal, enter the folder by CD instruction, initialize a new git

Git init

4. Add all files in the current folder directory to Git

git Add.

5. Submit the project to the local warehouse first

" Project "

6. Then push the local repository to the remote repository, where http://xxxxxxxx is the remote warehouse address , which is usually required after the address is added. Git links to the Git repository, if it's the first push, You also need to export the GIT user name and password of the remote repository for verification

Git remote add origin http://xxxxxxx.git
Git push-u Origin Master

Note: The common error for this step is that the remote repository will typically create a new Readme file when it is created, causing the upload to fail due to a file that does not exist locally on the remote repository

To Https://gitee.com/leisurezxy/iostest.git

! [Rejected] Master --Master (fetch first)

Error:failed to push some refs to ' https://gitee.com/leisurezxy/iostest.git '

Hint:updates were rejected because the remote contains work the

Hint:not has locally. This was usually caused by another repository pushing

Hint:to the same ref. Want to first integrate the remote changes

Hint: (e.g., ' git pull ... ') before pushing again.

Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.

The workaround is to execute the pull command first, merge the local nonexistent Readme file, and then execute the GIT push-u Origin master command to

Git pull--rebase Origin master

Three. Get existing items from Git, modify and submit

1. Based on the GIT address of an existing project, use the command-line tool to clone a repository remotely from a local

git clone https://xxxxxxx.git

2. After modifying the contents of the project, use the command line tool to enter the project folder, first execute the following two commands to submit the project to the local warehouse

git Add.
" Project "

3. Then execute the push command to synchronize the project to the remote Git repository

git push

Note: This step FAQ for Mac git set the global user name and password does not match the user name password used by the remote warehouse, need to be modified by the following command, the system will be prompted to enter the password

git config--global" user name "
git config--global" mailbox "

Common use of Mac git

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.