GitHub entry and daily operation commands (with two errors and solutions)

Source: Internet
Author: User
Tags commit git clone

What ' s git & git hub.

Development environment: Linux,git Tools


1. Register an account first.

2. Generate SSH Again (website very detailed, step-by-step)


3. Create a repository (used to put the Project warehouse) again.

Create and write the relevant name on GitHub first, and then create a folder in which to contact it locally.

$CD ~
$mkdir github_jff-rtos    //local directory name and repository name is not necessarily the same, related can be
$cd ~/github_jff-rtos      //Enter Github_ Jff-rtos Directory

Copy the code you want to host here:


If you select the 3rd step of 4, you need to perform the first

$git Pull Origin Master

From Github.com:mintist/jff-rtos
* Branch master, Fetch_head
Merge made by the ' recursive ' st Rategy.
. Gitignore |    ++++++++++++
readme.md | 4 ++++
2 files changed, insertions (+)
Create mode 100644. Gitignore
Create mode 100644 readme.md


Note: That's the two files that GitHub automatically helps you generate, pull it down first ~ ~ ~

otherwise ~ ~ ~ also nothing, go back first ~ ~ ~

$git init                             //initialization

Initialized Empty Git repository in/home/mintist/github_jff-rtos/.git/

$git Add.                            Add all the files to the index (do not want to add all the files, you can use Gitignore or add specific files, see below)
$git commit-m "OK, this is not       a rtos~~~"//Submit to the local warehouse, and then fill in the update log

4 files changed, 259 insertions (+)
Create mode 100644 Readme
create mode 100644 app.c
create mode 100644 Co RE.C
Create mode 100644 core.h

$git Remote Add Origin git@github.com:mintist/jff-rtos.git        //Add to Remote
$git Push Origin Master    //push (push) to GitHub

if (you Git pull Origin master as I say, you'll get)

Counting Objects:9, done.
Delta compression using up to 4 threads.
Compressing objects:100% (8/8), done.
Writing objects:100% (8/8), 2.96 KiB, done.
Total 8 (Delta 1), reused 0 (Delta 0) to
git@github.com:mintist/jff-rtos.git
c13a550. 109de37 Master, Master

Else

To Git@github.com:mintist/jff-rtos.git
! [Rejected] master, Master (Non-fast-forward)
error:failed to push some refs to ' GIT@GITHUB.COM:MINTIST/JF F-rtos.git '
to prevent-losing history, Non-fast-forward updates were rejected
Merge the remote changes (E  . G. ' Git pull ') before pushing again. See the
' Note about Fast-forwards ' sections of ' git push--help ' for details.
If you encounter an error, then PullJust a little bit better ~ ~


and some of the usual updates what to see below, pro-Test available ~ ~ ~


Summarize the commands commonly used in Ubuntu under GitHub, set part skipping, assuming repository's name is Hello-world:

1. Create a new repository:

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

$CD ~/hello-world//To Hello-world directory, the local directory name is not necessarily the same as the repository name

$git Init//initialization

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

$git Commit//Submit to the local warehouse, and then fill in the Update log (-M "Update log" can also, such as $git commit-m "My first vesion of ...")

$git Remote Add Origin git@github.com: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 the local warehouse, no parameters will prompt, note: ^=ctrl, follow the prompts to be good ~ ~ ~

$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 Git@github.com: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 git@github.com:wadeleng/hello-world.git

Error Tip: Fatal:remote origin already exists.

WORKAROUND: $ git Remote RM origin

Then execute: $ git Remote add Origin git@github.com: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.

//------------------------------------------------------------------------------

A Chinese git manual: http://progit.org/book/zh/


http://hi.baidu.com/wade_hit/item/848869db05e53af4cb0c391b


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.