Create git code under Linux

Source: Internet
Author: User

1. Create a new repository:

Create and write the relevant name and description on GitHub first.

$CD ~/hello-world//to Hello-world directory

$git Init//initialization

$git Add. Add all files to the index (do not want to add all the files, you can use Gitignore or add specific files)

$git Commit//Submit to the local warehouse, and then fill in the Update log (-M "Update log" can also)

$git remote Add origin [email protected]:wadeleng/hello-world.git//Add to Remote

$git Push Origin master//push to GitHub

2. Update the project (new file added):

$CD ~/hello-world

$git Add. This will automatically determine which files are added, or manually add the file name

$git Commit//submit to local warehouse

$git Push Origin master//not newly created, no more add to remote

3. Update the project (no new files, only delete or modify the file):

$CD ~/hello-world

$git commit-a//record which files were deleted or modified

$git Push Origin master//submit to GitHub

4. Ignore some files, such as *.O, etc.:

$CD ~/hello-world

$vim. Gitignore//Add the file type to the. Gitignore, save

Then you can git Add. can automatically filter this file

5.clone code to Local:

$git Clone [Email protected]:wadeleng/hello-world.git

If the code exists locally, and the repository has updates, merge the changes into the local project:

$git fetch origin//Get remote Updates

$git Merge Origin/master//merge updated content into local branch

6. Revocation

$git Reset

7. Delete

$git RM *//Not in RM

------------------------------Common Errors-----------------------------------

1.$ git remote add origin [email protected]:wadeleng/hello-world.git

Error Tip: Fatal:remote origin already exists.

WORKAROUND: $ git Remote RM origin

Then execute: Git remote add origin [email protected]:wadeleng/hello-world.git will not report an error

2. $ Git push origin master

error Hint: error:failed to push som refs to

Workaround: Git pull Origin master//put the file above github on the remote server first, then push it up.

Create git code under Linux

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.