How do I use GitHub under Ubuntu?

Source: Internet
Author: User

Install Git

A new ubunt system that requires git (the system does not have the tool), as follows:
Enter the following command in the Terminel:

sudo apt-get install git git-core git-gui git-doc git-svn git-cvs gitweb gitk git-email git-daemon-run git-el git-arch

Next you need to check SSH

Because GitHub uses SSH, you need to check in the shell to see if you can connect to GitHub:

ssh -T git@github.com

If you see:

warning:permanently added ' github.com,204.232.175.90 ' (RSA) to the list of known hosts.
Permission denied (PublicKey).

Then you can connect.

Reference

This assumes that you already have a GitHub user (if not, you need to register for GitHub)

Install SSH keys

Before installing GitHub, you'll need to install SSH keys

The first step : Check whether the well has SSH keys, if already have, then take the second step, otherwise, the third step

cd ~/.sshls

See if the directory already has SSH keys, and discover that there are no id_rsa (private keys) and id_rsa.pub (public key) two files

Step two : Back up and remove the existing SSH keys

mkdir

Back up the existing Id_rsa,id_rsa.pub file to the Key_backup folder

Step three : Execute the following command (without SSH keys):

ssh-keygen-t-C"你自己的github对应的邮箱地址"

Note 1: "" is needed!
Note 2: It's in the SSH directory!

The results were as follows:

found that the Id_rsa (private key) and id_rsa.pub (public key) of these two files were created
(See all the contents of ~/.ssh below with LS view)

Fourth Step : Add the SSH keys you just created to GitHub
(1) Use the Gedit/cat command to view the contents of the Id_rsa.pub
(2) in GitHub, click Settings-ssh keys, add ssh Key, copy the strings in the Id_rsa.pub file, and note that there are no line breaks and spaces in the string.

Fifth Step : Check the SSH connection again (in the ~/.SSH directory):

Enter the following command:

ssh -T git@github.com

If you see the following, it means that you added success:

Hi alioth310! You've successfully authenticated, but GitHub does not provide shell access.

At this point, you find that you already have SSH keys on GitHub.

Note 1: If you set a password before setting the public key, you will be asked to enter a password in this step, then enter the password you set at that time.

Note 2: With the above settings, you will be able to access the GitHub hosting server directly using the git command via SSH.

Get started with GitHub

Refer to the Liaoche GitHub tutorial; a simple github tutorial
; Linux operation git remote repository synchronization with the local repository tutorial;

Configure Git

Using your own username and email address to configure Git

git config --global"你的github用户名"git config --global"你的github邮箱地址"
How to push local content to a newly created warehouse on GitHub on GitHub to build a new warehouse

The concrete content does not introduce, assumes, the new warehouse is Dockerfiels

To create a directory locally

The directory name is the same as the new GitHub-created directory, assuming the local directory is ~/document/dockerfiles

Local Warehouse Initialization
cd ~/Document/dockerfilesgit init
Make changes to the local warehouse

For example, add a Readme file

touch Readme
Submit the changes you just made

This step must not be omitted!

commit -m ‘add readme file‘
Push

First, you need to associate the local warehouse with the GitHub warehouse
Note: https://github.com/your github username/your github repository. Git is the URL of a repository on GitHub

add origin https://github.com/你的github用户名/你的github仓库.git  

Then, push, you may need to enter your GitHub account and password and enter it as required.

push origin master
How to push local content to existing warehouses on GitHub clone the warehouse from GitHub
clone https://github.com/你的github用户名/github仓库名.git  
Make changes to the clone down warehouse

For example, add a new file

touch Readme_new
Submit the changes you just made

This step must not be omitted! (actually commit to git cache space)

‘addnewfile‘
Push

First, you need to associate the local warehouse with the GitHub warehouse
Note: https://github.com/your github username/your github repository. Git is the URL of a repository on GitHub

add origin https://github.com/你的github用户名/你的github仓库.git  

Sometimes, Fatal:remote origin already exists., then, you need to enter GIT remote RM origin to resolve the issue

Then, push, you may need to enter your GitHub account and password and enter it as required.

push origin master

Note: Sometimes, when executing GIT push Origin master, error: error:failed to push som refs to ..., then, you can perform

git pull origin master

At this point, the existing warehouses on GitHub are updated

If you need to add a folder, one thing to note: This folder cannot be empty! Otherwise, it cannot be added successfully

Summary of OPERATIONAL commands
    • Cloning existing warehouses on GitHub
clone https://github.com/你的github用户名/github仓库名.git
    • or create a new warehouse on GitHub and create a new warehouse with the same name locally
cd ~/Document/dockerfilesgit init
    • Make changes to the contents of the local repository (if this is done more than once on a local warehouse, just start with this step, not the previous operation, because the local repository already has a. git file with the GitHub repository)

    • Submit changes to the content

add 更改文件名或者是文件夹名或者是点".""commit内容标注"
    • Local warehouse associated with GitHub warehouse
add origin https://github.com/你的github用户名/你的github仓库.git  
    • Push
push origin master

Note: Additional commands that may be used

remote rm origingit pull origin master
View current git cache space status
git status

How do I use GitHub under Ubuntu?

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.