Intellij IDEA Tutorial (seven) GitHub use

I. Introduction

Git is the world's most advanced distributed version control system.

Git and SVN differences:

SVN is centralized version control system, the repository is focused on the central server, and work time, are used in their computers, so first of all from a central server where to get the latest version, and then to work, finish , we need to finish the job on their own to a central server. Centralized version control system must be networked to work, if it can, the bandwidth is large enough in LAN, fast enough, if in the Internet, if Suman, then wonder.

Git is a distributed version control system, then it has no central server, each person's computer is a complete repository, so that when things do not need to work, because the versions are on your own computer. Since everyone's computer has a complete repository, how much how individuals collaborate it? For example, to change their own files on the computer A, the others are changed A file on the computer, then, you just need to give each other their own changes pushed between the two, we can see each other's changed.

II. Download and install Git

GitHub is the most popular version control software, Official Download
Here Insert Picture Description
to start the installation after the download, unzip
Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Git black window opens, enter git -version to see if the installation was successful
Here Insert Picture Description

III. Configuring SSH

In the black window, enter the command ssh-keygen -t rsa -C "your email address" and has a carriage return
Here Insert Picture Description

In C: \ Users \ became the secret key file WangPan.ssh swells directory, use Notepad to open id_rsa.pub file and copy the contents inside
Here Insert Picture Description

Then log github website, then follow the instructions, and then click Add
Here Insert Picture Description
after the addition was complete as shown below
Here Insert Picture Description

IV. Configuring account and mailbox

Enter the command line window at the black run the following command:
git config --global user.name "your username"
git config --global user.email "your email"
Here Insert Picture Description

Five .IDEA Configuration Git

After opening the settings, go git configuration path, click Apply
Here Insert Picture Description

Six .IDEA submit Git (via git command)

Pop-up command window after the first project in a new idea, and then go to the directory right into the project
Here Insert Picture Description

Click the plus sign in the upper right corner Github

Here Insert Picture Description

Then enter the following command in the just opened black window

  1. git init // initialize warehouse

  2. git add. (file name) // add files to a local warehouse

  3. git commit -m "first commit" // add file description information

  4. git remote add origin + remote warehouse address // link remote repository, create the main branch

    Note that this step if there is no master main branch can be omitted

  5. git pull origin master // change the local repository connection to a remote repository main branch

  6. git push -u origin master // push the local repository of files to a remote warehouse
    sixth step will pop up the following figure, when submitted, only the first will pop up, enter your user name and password to log

Here Insert Picture Description

Here Insert Picture Description

Submit completed
Here Insert Picture Description

Seven .IDEA submit Git (by the idea)

In the menu click VCS -> Import into Version Control - > Create Git Repository
ejection path selection box, the default on the line in the project directory, create a local warehouse

Here Insert Picture Description
Here Insert Picture Description
More a .git folder description repository is created, then click on the following, click Add files are red to green, it is already successfully added
Here Insert Picture Description

Then click on the figure below to begin submitting to add commit

Here Insert Picture Description

Here Insert Picture Description

Submit complete turns white, then just submit to a local warehouse, you are required to submit to a remote repository

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

Tip successfully completed, attention in multiplayer development environment, you must first submit updated in order to avoid conflict

Here Insert Picture Description

Eight .IDEA Git update

Here Insert Picture Description

Here Insert Picture Description

Nine .IDEA Git reduction

Here Insert Picture Description

Here Insert Picture Description

Ten .IDEA Git clone

Here Insert Picture Description
Select the clone project, then click clone
Here Insert Picture Description
prompted, click yes, then the next step has been completed until
Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description

Git off eleven .IDEA

File -> Settings -> Version Control click on the delete button to the right
Here Insert Picture Description

Then delete the .git folder
Here Insert Picture Description

Twelve .IDEA Git file Color Description

Here Insert Picture Description
Here Insert Picture Description

Thirteen .Git instructions and principles

After using git init command generates .git hidden folder
Here Insert Picture Description

  • config file: This file is mainly recorded some configuration information for the project, such as whether to initialize bare, remote information and other information through the git remote add command to increase the remote branch is saved here;

  • objects folder: This folder contains the main git object. About what is git object will be described in detail in the next section. Git files and some of the operations to git will object to hold, git subjects were divided into BLOB, tree and commit three types, such as git commit git commit object is in, and between the various versions is organized by version tree such as the current HEAD will point to a commit object, and the object will point to the commit several BLOB objects or tree object. objects folder contains subfolders number, wherein the object is stored in the first two Git its sha-1 value for the sub-folders, files 38 bits of the file name; In addition, in order to save storage Git the disk space occupied by the object, the object periodically to Git compresses, packages, which pack folder to store packed compressed objects, and info folder used to find objects from the git package of documents;

  • HEAD file: This file indicates git branch (i.e., the current branch) results, such as the current branch is the master, the master file will point, but not store a master string, but shows a branch in refs, e.g. ref: refs / heads / master.

  • index file: This file holds information about the staging area. The document is to some extent a buffer (staging area), including time stamp, file name, sha1 value it points to a file and so on;

  • Refs folder: This folder stores data points (branches) submitted object pointer. Which heads the local storage folder for each branch of the last commit sha-1 value (that is, commit object sha-1 value), each branch a file; remotes folder you communicate your last record and each remote repository , Git will you last pushed to that remote for each branch value are recorded in this folder; tag folder is an alias branch, there is no need because they have too much to understand;

  • hooks mainly defines the client or server-side hook scripts, which are mainly used for specific processing before specific commands and operations, or after, for example: when you push the local repository to the remote repository server, you can warehouse server hooks on the web server folder defined post_update scripts that can be deployed to a server in the script by script code latest code, which will release the code version control and seamless connection together;

  • description file only GitWeb program, there is no need too much care;

  • logs the records submitted by the branch of a local warehouse and remote repository for each record that all commit objects (including time, author and other information) will be recorded in this folder, so the contents of this folder is that we see the most frequent, whether Git log command or tortoiseGit the show log, need to obtain from the commit log folder;

  • info folder management do not want to save a file in .gitignore ignore patterns of global executable file, basically do not have access; COMMIT_EDITMSG file records the last annotation information submitted.

From the above description we can see, .git folder contains the folders and files of many different functions, these folders and files Git repository is essential description, can not be altered or deleted; in particular, Note that, .git folder with the evolution of the project, may become bigger and bigger, because any change in any file, Git will need to be re-stored as a new object file in the folder objects Therefore, if a file is very large, then you submit several changes will result in .git folder capacity doubled. Therefore, .git folder is more like a book, every change in each version is stored in this book, and this book is also a directory, pointed out the different versions of changes in the content stored in the book on which page, which is the most basic principles of Git.

Published 75 original articles · won praise 44 · views 510 000 +

Guess you like

Origin blog.csdn.net/u013254183/article/details/105294310