Easily use git commands to create code repositories and git command code repositories

Source: Internet
Author: User
Tags how to use git git commands git shell

Easily use git commands to create code repositories and git command code repositories

We can easily use the git command to upload code modifications. In this article, we will learn how to use git to create a repository.
Five-step command for creating repository:

  • Git init
  • Git add-all
  • Git commit-m <comment>
  • Git remote add origin https: // gitserver/username/projectname. git
  • Git push-u origin master
Local DatabaseStep 1, Git init

Open git shell (Environment: Take windows as an example, install the Github client and configure the account information). By default, it is in the git workspace path, the ls command can view all directories in the workspace (recommended: the directory in the workspace should be in the Project Unit), and the cd command enters the target project.
First, create our own project:

mkdir MyProject

Init initializes the directory to the git control environment

git init

After init, there will be more folders named by. git (in linux, they will be hidden and do not need to be concerned ).

Step 2, Git add-all

If your project code is ready, copy it to the local directory.
Note:Taking the Android project under eclipse as an example, the current git project directory and Android project are the same root directory, that is, the copied result is the src directory, and the direct subdirectories of the two projects are the same.
We already know that the add command only enables the file to enter pre-commit. In this status, we can freely edit the file status:

git add --all

After execution, all the new files enter the pre-commit status.

Step 3, Git commit-m <comment>

Modify commit to make it a node ):

git commit -m "initial commit"
Remote AccessStep 4, Git remote add origin https: // gitserver/username/projectname. git

Create a remote code library on github and set the local repository:

git remote add origin https://gitserver/username/projectname.git

All right, this 1.1 is weird at first, and the actual usage only understands the actual meaning: The repository that has been used locally will be converted to the repository of remote storage for access.

Step 5, Git push-u origin master

Before submitting our project, we also need to synchronize the content from the server to the local, because the README. md and LICENSE files are created when a new project is created using github.

git pull origin master

After execution, you can execute synchronous upload if there is no conflict:

git push -u origin master

In a Windows environment with Github configured, you do not need to enter the account password in this step. However, in other cases, you may be asked to enter the account password. Note that the password is not displayed.
Okay, we used the git command to create a code repository and complete the project code upload remote repository.

Here is an additional basic git knowledge. You may need to surf the Internet to watch it.

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.