Mac under GitHub command operation

Source: Internet
Author: User
Tags svn git clone

Because GitHub is so useful ~ ~, a variety of source code, open source engineering, often need to download down to use and learn, or your own code needs to upload and the like, despite the "GitHub for Mac" tool, but as a program Ape!! or study the use of TERMINAL commands!! This looks high-end atmosphere on the grade! Ha ha!

First: Create a GitHub account: https://github.com/---> Pricing and Signup---> Create a free accounts creating an SSH public key:

Open Terminal

$CD ~/.ssh  //Check if SSH is already present

If it exists, first make an existing SSH backup, or build the new SSH into a different directory

If not present, SSH is generated directly from the default parameters

$ssh-keygen-t rsa-c [email protected] (email when you register for GitHub)        generating public/private RSA key pair.
        In which to save the key (/users/twer/.ssh/id_rsa): /users/rdc-hankang/desktop/a folder
(It is best to enter directly here!!!) Sometimes need to be saved in the /users/twer/.ssh/directory, or finally can not be connected to the Gethub official website, may be related to the use of black apples, using Mac The CP command copies the. pub file to copy the key pasted on the GitHub official website, where key and SSH are associated with another, i.e. No. pub suffix )                Enter passphrase (empty for no passphrase): Create a password
        Enter same passphrase again: duplicate password
        Your identification has been saved In/users/twer/.ssh/id_rsa.        Your public key has been saved in/users/twer/.ssh/id_rsa.pub.        The key fingerprint is:        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx [email protected] The        key ' s randomart image is:        +--[RSA 2048]----+        |. r.+-=+=         |        |. rro.+. .       |        |  .. * = A.      |        |   o = + E       |        |      . S o      |                 |       | | | | | | | | +-----------------+
add ssh to GitHub: Login to GitHub, select Account settings-->ssh Keys to add SSH title:[email protected]//Do not know what is the use of this side, not sure whether it is a new mailbox or a registered GitHub mailbox, It doesn't feel right. Key: Open the Id_rsa.pub file you generated, copy all of the contents to this point and need to start with text. ssh-rsaaaaab3nzac1yc2eaaaadaqabaaabaqdar+fdaagdarg8j1m+ like this. jpkjsonmmyvee7lq5baabzpdcrakgywllslkeyjxzelxkdt2yzimb41fjqcvzzkzhzk0gnldy8xd5umcmkjoy2ef0kjr0y7zlu/ bltt5ta6nivz49mksbtgsjyvbcyv16oncua9sokpjgv7ediznwjvaowjah4edbpofamz8whwnopochjdi3wlz7ofkw5/ wj5d0tvvt9knu0zcwzgrfpmveqc1chkw8epicnjtjrtyw0vlngrozev67atvzicqx7ulomna78tnefzseyupbydbr6jepiflxzhmvbpm4tdzi/ undf+z1jqjyplkzjiyu2lr/[email protected] Test account with github link situation: ssh-t [email protected] Here is the GitHub website, if the following prompts, indicating that you have connected.
Hi haleyhan! You've successfully authenticated, but GitHub does not provide shell access.
The next step is to manage your code. Remotely build engineering and interact with Local:

Build your own repository on GitHub. Create a New repository is as follows:

    • Repository name: Usually write your own project name to build.
    • Description: That's your description of the project.
    • Select public.
    • Click "Create Repository" to appear as:

List of commonly used commands and usage: When the computer is first used (meaning input once, this computer is useful for life): [OBJC]View PlainCopy 
    1. Git init //git initialized (after local directory)
[OBJC]View PlainCopy 
    1. Git remote add origin url //url: URL for new project

Submit: [OBJC]View PlainCopy 
    1. git Add. //All modification works in this directory are submitted to the local warehouse
[OBJC]View PlainCopy 
    1. git commit-m "up" //must step to describe the update
[OBJC]View PlainCopy  
    1. Git push Origin master //update the local repository to the remote repository

To add a new file: [OBJC]View PlainCopy 
    1. git Add. //Add all newly added files in this directory
[OBJC]View PlainCopy 
    1. git commit-m "up" //Description Add File
[OBJC]View PlainCopy 
    1. Git push Origin master //update
To delete a file: [OBJC]View PlainCopy 
    1. git Add. //Add all newly updated files in this directory
[OBJC]View PlainCopy  
    1. git commit-m "de" //description file
[OBJC]View PlainCopy 
    1. git rm "files" //delete files
[OBJC]View PlainCopy 
    1. Git push Origin master //update
Download Project: [OBJC]View PlainCopy 
    1. git clone URL //url is a remote URL
Remote relative local update: [OBJC]View PlainCopy 
    1. Git pull Origin Master
The above command is basically enough to solve the bug in the process:

1: If you enter git remote add origin [email protected]:d Jqiang (GitHub account name)/gitdemo (project name). Git

Tip error Message: Fatal:remote origin already exists.

The solution is as follows:

1. First enter GIT remote RM origin

2, then enter the GIT remote add Origin [email protected]:d jqiang/gitdemo.git will not error!

3. If you enter GIT remote RM origin or an error, error:could not remove config section ' Remote.origin '. We need to modify the contents of the Gitconfig file

4. Find your GitHub installation path, mine is C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\ etc

5, find a file named Gitconfig, open it to the inside of the [remote "origin"]那一行 delete it!

2: If you enter $ ssh-t [email protected]

error message: Permission denied (PublicKey). Because the newly generated key cannot join SSH, it will cause the connection to not be on GitHub.

The solution is as follows:

1, first enter $ ssh-agent, and then enter $ Ssh-add ~/.ssh/id_key, so you can.

2, if still do not, enter Ssh-add ~/.ssh/id_key command after the error could not open a connection to your authentication agent. The workaround is key with the Git GUI SSH tool Generated, so that when the key is stored directly in SSH, do not need to ssh-add command to join, and other user,token and other configurations are done with the command line.

3, it is best to check if you copy the contents of the Id_rsa.pub file there is no extra space or blank lines, some editors will help you add these.

3: If input $ git push origin master

Tip error message: error:failed to push som refs to ....

The solution is as follows:

1. First enter the GIT pull Origin master//start the remote server github file down

2. Then enter $ GIT push origin master

3. If an error occurs FATAL:COULDN ' t find remote ref Master or fatal: ' Origin ' does not appear to be a git repository and fatal:could not Read from remote repository.

4. You need to re-enter Git remote add origin[email protected]:d jqiang/gitdemo.git

When you create a new Xcode project, if you find a. svn and. Git in the directory, you can selectively delete:

Delete all. svn files under a folder

Find. -name ". SVN" | Xargs RM-RF

Delete all the. git files under the folder find. -name ". Git" | Xargs RM-RF-Reprint

Mac under GitHub command operation

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.