Git/GitHub Application

Source: Internet
Author: User

I have been familiar with GIT and SVN for a long time, but I have never used it for version control management. Although SVN has been useful, I think it is better to use git, especially GitHub.

Git terminology

Terms Definition
Warehouse A repository contains all version information, all branches, and tag information.
Repository Each copy of the repository in git is complete. Warehouse allows you
  Get your work copy.
  A branch means an independent code line with its own historical information.
Branch (Code line ). You can generate a new branch from the existing code.
Branches The Branch is completely independent from the remaining branch. The default branch is usually called
  Master. You can select a branch named
  Checkout.
Mark A tag refers to the status of a branch at a specific time point. Pass mark
Tags Note, you can easily switch to the status when marking, such as August 25, 2014
  Code status on the testing Branch
Submit After the code is submitted, the repository creates a new version. This version can be found in
Commit It will be acquired again later. Each submission includes the author and submitter, author, and
  The submitter can be a different person.
URL A URL is used to identify the location of a repository.
  Indicates a version status of the Code. Git uses the sha1 hash algorithm
Revision ID to identify different versions. Each sha1 ID is 160 characters long.
Revision , A hexadecimal string. The latest version can be obtained through the head.
  For previous versions, you can use "head ~ 1 "to get, and so on.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Index

Git needs to associate the code changes with the next commit. For example, if you continue to modify a file and want to submit the modifications to the next submission, you must submit the file to the index, run the GIT add FILE command. In this way, indexes can save all changed snapshots.

Newly Added files must always be displayed and added to the index. For files that have already been submitted, you can use the-A option in the commit command to submit to the index.

Git Installation

On Ubuntu, you can use apt to install the GIT command line tool.

sudo apt-get install git-core

Git Configuration

You can prevent global configuration of git in the. gitconfig file. The file is located in the user's home directory. As mentioned above, the information of the author and the submitter will be saved for each submission, which can be saved in the global configuration. The following describes how to configure user information, highlight and ignore specific files.

  • User Information

Use the following command to configure the user name and email

git config --global user.name "Example Surname"

git config --global user.email "[email protected]"# Set default so that all changes are always pushed to the repositorygit config --global push.default "matching"

To obtain git configuration information, run the following command:

git config --list
  • Highlight
git config --global color.status autogit config --global color.branch auto
  • Ignore specific files

You can configure git to ignore specific files or folders. These configurations are stored in the. gitignore file. This file can exist in different folders and can contain different file matching modes. To allow git to ignore the bin folder, put the. gitignore file in the main directory, where the content is bin.

GIT also provides global configuration, core. excludesfile.

  • Use. gitkeep to track empty folders

Git ignores empty folders. If you want to include empty folders in version control, the. gitkeep file will be placed in an empty folder by convention. In fact, there are no specific requirements for file names. Once a file exists in an empty folder, the folder is within the version control scope.

GitHub operations

  • Get key
ssh-keygen -t rsa -C "[email protected]"
  • Log on to the GitHub System

Click account settings ---> SSH public keys ---> Add another public keys

Put your locally generated key (~ /. Ssh/id_rsa.pub file) copy to it (in the key text box), click Add key to OK

  • Start git and test whether the connection is successful.
ssh -T [email protected] 

Note: Hi defnngj you 've successfully authenticated, but GitHub does not provide shell access.

  • Create a project on GitHub

Click "new repository" in the lower right corner of the page"

Enter the project information and click "create repository". Now a project is created on GitHub.

  • Clone a new project on GitHub
Git clone [email protected]: xxxx/xxxxx-demo.git // git clone [email protected]: User Name/project name. Git
  • Submit changes
Git add.
Git commit-M "new files" Git push
# Or
Git remote add origin [email protected]: xxxx/xxxx-demo.git
  • Update version
Git fetch origin // obtain remote updates. here we can see that we are preparing to take git merge origin/Master // and merge the updated content to the local branch/master.
  • Common simple commands
Git remote-V // view the repository address that is remotely connected to your current project. Git status // view the status of all files in the current project,
  • Connect a remote project with a local project
git remote add origin [email protected]:xxxx/xxxx-demo.git

I am the dividing line of tiantiao

 

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.