Using GIT commands and GitHub projects under Linux

Source: Internet
Author: User
Tags using git git clone git commands docker hub

Using GIT commands and GitHub projects under Linux

Description: Tested OK on August 26, 2017 (metalworking)

Build a git environment under Linux

1, registered GitHub account, website: https://github.com

2, Linux create SSH key:

Method one: Ssh-keygen # #一直默认就可以了


Method Two: Ssh-keygen-t rsa-c "[email protected]"//Generate key, mailbox ibid.

Cat ~/.ssh/id_rsa.pub//Submit key, copy the key inside


Method Three: Non-interactive generation key: Ssh-keygen-t rsa-n "-F ~/.ssh/id_rsa-c" [email protected] "


3. Add the public key to the GitHub account information accounts settings->ssh key

Method: Login to the GitHub Web page to login to your account, and then setting, find SSH key to copy the key to join (need to re-enter the github password)


4. Test verification is successful.

ssh-t [email protected] Prompt successfully description successful

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


Sync GitHub to Local

1. Copy the project to Local:

git clone [email protected]:rshare/docker-installer.git # #以SSH方式克隆到本地, can read and write

git clone https://github.com/rshare/docker-installer.git # #以https方式克隆到本地, can read and write


Other commands for Git synchronization:

git clone git://github.com:xxxx/test.git # #以gitreadonly方式克隆到本地, can only read

git clone [email protected]:xxx/test.git # #以SSH方式克隆到本地, can read and write

git clone https://github.com/xxx/test.git # #以https方式克隆到本地, can read and write

git fetch [email protected]:xxx/xxx.git # #获取到本地但不合并

git pull [email protected]:xxx/xxx.git # #获取并合并内容到本地


Submit a project locally to GitHub

1. Local Configuration

git config--global user.name ' Onovps ' #设置用户名标识

git config--global user.email ' [email protected] ' #全局联系方式, optional

git config--list #查看git环境设置


2. Create a new Git project and submit it to GitHub.

mkdir testdir && CD TestDir

Touch readme.md

Git init #初始化一个本地库

git add readme.md #添加文件到本地仓库

git rm readme.md #本地倒库内删除

Git commit-m "First commit" #提交到本地库并备注, at which time the change is still local.

Git commit-a # #自动更新变化的文件, a can be understood as auto

git remote add xx [email protected]:rshare/docker.git #增加一个远程服务器的别名.

Git remote rm xx # #删除远程版本库的别名

git push-u remotename master #将本地文件提交到Github的remoname版本库中. The local changes were updated to the GitHub service at this time.


Branch version operation

1. Creating and Merging branches

Git branch #显示当前分支是master

Git branch new-feature #创建分支

git checkout new-feature #切换到新分支

VI index.php

git add index.php

Git commit-a-M "added initial version of page cache"

Git push Origin new-feature # #把分支提交到远程服务器, simply commits the branching structure and content to the remote, and does not occur with the trunk merging behavior.


2, if the New-feature branch mature, it is necessary to merge into Master

git checkout Master #切换到新主干

git merge New-feature # #把分支合并到主干

Git branch #显示当前分支是master

git push #此时主干中也合并了new-feature code


--------------------------------------------

Example: RShare personal GitHub synchronous data combat.

1th step, Login to GitHub:

1, registered GitHub account, website: https://github.com My account: rshare Password: pass000

2, Linux create SSH key:

Method One: Non-interactive generate key: Ssh-keygen-t rsa-n "-F ~/.ssh/id_rsa-c" [email protected] "

Cat ~/.ssh/id_rsa.pub//Submit key, copy inside key (3rd step to paste)

Description: Ssh-keygen is the SSH key generator, the-t specifies that the algorithm is rsa,-n to specify the password is empty,-f specifies the private key location,-c Specifies the comment information (not specified as the host name).

3. Add the public key to the GitHub account information accounts settings->ssh key

Method: Login to the GitHub Web page to login to your account, and then setting, find SSH key to copy the key to join (need to re-enter the github password)


4. Test verification is successful.

ssh-t [email protected] Prompt successfully description successful

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


# #同步github到本地

1. Copy the project to Local:

Mkdir/test

Cd/test

git clone [email protected]:rshare/mydocker.git # #以SSH方式克隆到本地, can read and write

git clone https://github.com/rshare/docker-installer.git # #以https方式克隆到本地, can read and write

LS View file list


2. Create a new file and upload it to GitHub.

Cd/test/mydocker

Ls-a

Git remote

Cp-v/etc/{hosts,group,passwd}./

Git add hosts group passwd

git status

Git commit-m ' 3files '

Git push-u Origin Master

Verify: See if there are three more files (HOSTS,GROUP,PASSWD) in the Mydocker warehouse on the GitHub personal site.


git other commands:

Git branch #查看分支 (that is, directory structure)



3. Delete the files in the remote repository.

Cd/test/mydocker

Ls-a

git RM--cached hosts group passwd #删除缓存数据, does not delete local files

git status

git commit-m "hehe"

Git push origin

Verify: See if three files (hosts,group,passwd) are missing from the Mydocker warehouse in the GitHub personal site.

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A2/84/wKioL1mhLzLyag8jAABtT2HzZkY894.png "title=" Git_ Hub.png "alt=" Wkiol1mhlzlyag8jaabtt2hzzky894.png "/>


= = = Use of the network Docker hub =============

flyer520 Yes docker image download and upload instance:

1 step , register docker-hub Span style= "font-size:14px;font-family: ' Microsoft Jas Black ', ' sans-serif '; color: #3F3F3F;" > account number. In https:// hub.docker.com/ website registration.

Note: My account number is flyer520 , Mailbox [email protected]

2 step, linux login docker test.

My account: Docker Login--username=flyer520 [email protected] ( login OK)

To View login information: Cat ~/.docker/config.json

Section 3 step, download Docker mirroring.

Docker Pull BusyBox

Docker Pull Nginx

Docker images

Section 4 Step, modify the label ( reset label ) .

Test1: ModifyNginxlabel, andPushuploaded toflyer520of theDocker-hubthe.

Docker tag Nginx Flyer520/nginx

Docker Push Flyer520/nginx

Test2: ModifyBusyBoxlabel, andPushuploaded toflyer520of theDocker-hubthe.

Docker tag BusyBox Flyer520/busybox

Docker Push Flyer520/busybox

verify: Log on to Docker-hub to see if there's more. Nginx mirroring.

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/A2/84/wKioL1mhLtbTn3VpAACk9xJHD2Q721.png "title=" Docker_hub.png "alt=" Wkiol1mhltbtn3vpaack9xjhd2q721.png "/>


Cond....


In this, the experiment is finished.


This article is from the "Network Technology World" blog, please be sure to keep this source http://1364952.blog.51cto.com/1354952/1959524

Using GIT commands and GitHub projects 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.