REDHAT7 Git installation using

Source: Internet
Author: User

Git is a very powerful distributed version control system. It is not only suitable for managing the source code of large open source software, but also has many advantages in managing private documents and source code.

Build a Git environment

First step: Install Git

# yum-y Install git

Step two: Create a GitHub account on https://github.com/

Step three: Generate SSH key

# ssh-keygen-t Rsa-c "[Email protected]"

Fourth step: Go back to GitHub, click Configure email settings, ssh keys, Add ssh key, title fill, paste Key

Fifth step: Test if SSH key is successful if you have successfully authenticated, but GitHub does not provide shell access. This means that you have successfully connected to GitHub.

# ssh-t [email protected]

Sixth step: Configure git configuration files, username and email

# git config--global user.name "your name"//Configure user name

# git config--global user.email "your Email"//Configure Email

Use Git to upload to GitHub from the local

Step one: Go to the directory where you want to upload the file enter the command "Git init"

# mkdir TestDir & CD TestDir

# git Init

Step two: Create a local repository Origin,youname is your github username, Yourrepo is the repository you want to upload to GitHub

# git remote add origin [email protected]:yourname/yourrepo.git

The third step: for example, you want to add a file xxx to the local repository, using the command "git add xxx", using the command "Git commit-m" to explain the submission ""

Finally, submit the local repository origin to the remote GitHub repository using the command "Git push Origin master"

# Echo This is a readme file. >> readme.md

# git Add readme.md

# git commit-m "First commit"

# Git push Origin Master

View the status of Git's current repository

# git status

View the current repository log log

# git log

Delete a file from the local repository

# git rm-f < files >

# git RM-RF < folders >

Cloning projects from GitHub to local

Step one: Go to a warehouse in GitHub and copy the "HTTPS clone url" to the right

Step two: Go back to the directory you want to store, use the command "Git clone https://github.com/chenguolin/scrapy.git", the red URL is just an example

Step three: If the local version is not up-to-date, you can use the command "Git fetch origin", Origin is the local repository

Fourth Step: Merge the updated content into the local branch, you can use the command "git merge Origin/master"

If you do not want to manually merge, then you can use: Git pull < local repository > master//This command can be pulled to the latest version and automatically merged

GitHub's branch management

Create

1 Create a local branch: GIT branch < new branch name >

2 Synchronizing a local branch to GitHub: Git push < local repository name > < new branch name >

3 Switch to the newly established branch: Git checkout < new branch name >

4 Add a new remote end to your branch: Git remote add < remote End name > < address >

5 View the current warehouse has several branches: Git branch

Delete

1 Delete a branch from the Local: git branch-d < branch name >

2 Sync to github Delete this branch: git push < local repository name >:<github End Branch >

5 Common errors

1 If an error is error:repository not found.fatal:The remote end hung up unexpectedly is the wrong URL link for your origin, it could be a creation error or this [Emai L protected]:xxx/new-project.git URL specified incorrectly. Re-create.

REDHAT7 Git installation using

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.