Mac OS X command line submit local project to Git

Source: Internet
Author: User

Mac OS X command line submit local project to Git

In the past, Git was used on the GUI. Today, we have the opportunity to perform a practical operation on the text interface. I recorded the process for anyone who needs it.

Note: The starting position of $ is a command line ($ does not belong to a command), and no result is output.

1. Before using the git command tool, make sure that you have installed the git command tool. If git is installed in your system, enter the git command on the terminal to view the relevant information.

1 $ git -- version

2 git version 2.4.9 (Apple Git-60)

2. If not, you can install Xcode Command Line Tools. You only need to install the necessary Command Line. The package is not large. (Its built-in git environment)

1 $ xcode-select -- install

3. Create a remote git Project (I believe everyone will skip this step)

4. I copied the previous git project as a new local project and submitted it to a new git Project (you can create a local project)

The purpose here is to introduce git initialization. After a project becomes a git project, a hidden. git file contains git information. When you copy a git project and submit it as a new project, you must delete the. git hidden file in the project. Otherwise, the git Information contained in your project is still in the previous project, and will be submitted to the previous project.

A. Switch to the directory of the project you want to submit on the terminal (please switch to the actual directory location of your project)

1 $ cd/Users/my_mac/Documents/workspace/copy-project

B. view all files in the directory (including hidden files)

1 My-MacdeMacBook-Pro: copy-project my_mac $ ls-

2. git. settings pom. xml

3 .. gitignore assembly. xml src

4. classpath. project doc target

C. Delete the. git directory

1 $ rm-fr. git

1 My-MacdeMacBook-Pro: copy-project my_mac $ ls-

2. gitignore assembly. xml src

3 .. project doc target

4. classpath. settings pom. xml

Now that the deletion is successful, you can submit the operation. (If a new project is created, the c operation does not exist)

5. submit the project to git.

Run the following commands in the directory of the current project:

A. initialize git and create an empty Git repository

1 $ git init

B. Add the current directory and all its subdirectories and files

1 $ git add.

C. submit it to the local repository

1 $ git commit-m "New Project"

D. push to the remote repository (Use http protocol and enter your own url)

1 $ git remote add origin http://XXXXXXX.git

1 $ git push-u origin master

During the above operation, if it is the first time, you may also need to enter your git username and password to verify the git permission. If permission denied is encountered during statement execution, add sudo to the command.

6. git clone

Your git project has been successfully created. If you download a remote git project through eclipse, a git directory will be created under your root directory by default, and the project will be put in this directory. You can also execute this operation through the command line.

1. Create a git directory under the root directory

1 $ cd ~

1 $ mkdir git

2 $ cd git

1 $ git clone http://XXXXXXXXX.git

2. Then, you can import the git project locally in eclipse.

If a friend is not familiar with the above commands. You can enter the command you want to query on the terminal, for example, input man mkdir to print the usage and parameters of mkdir.

The git official website provides more detailed git operation commands. You can view the learning information on your own.

7. done

Git Tutorials:

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Share practical GitHub tutorials

How to Build and use Git servers in Ubuntu

Git details: click here
Git: click here

This article permanently updates the link address:

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.