Notes [1] local Git and GitHub project interconnect remote repository

table of Contents

 

1. Why do many companies choose Git

2. Learn what Git ready to work?

3. How to create a local repository that?

4. remote repository

5. The local repository to push Github

On 6.Github cloning project to a local warehouse

 Autumn recruit interview, the interviewer asked me: Do you Git it? I hesitated looked at him, he smiled and said, before entry to seize the time to learn about.

Due to geographical advantages to be familiar with the environment at the company, consulting algorithm head of pre-employment can do to prepare? Leader said, Git to learn about this very important work. However, I did not listen, regret, really wasted a lot of time on using Git, you might say Git is not difficult, yes, it is not difficult, but it will be, you really will increase work efficiency, things Git or very much.

This series is to grasp the trunk study notes, sort of work will be commonly used commands. So setting up the environment! Starting with local and remote repository interconnection project began, some concepts will not, all right, if the back will catch highlights the period.


1. Why do many companies choose Git

   1.1 Why Git  

Git official website for its introduction is this: Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency (Git is a free, open-source distributed version control system, it is. can quickly and efficiently handle all projects from small to large)

Git is easy to learn and has a tiny footprint with lightning fast performance. (Git easy to learn, small footprint, performance, lightning fast)    

 Sentence summary: Git is the world's most advanced distributed version control system that helps individuals or corporate teams a powerful tool for version control, - everything-is-local.

We are more familiar: knowledge Github, Gitlab, there appears to share CSDN payment platform Gitchat are based on such a thought. Just yesterday (September 17, 2019), GitLab announced that the company has completed 268 million US dollars worth of E round of financing, has been ready for the IPO, plans to go public in 2020 November 18.


2. Learn what Git ready to work?

1. Install Git: https: //git-scm.com/download

Study notes the system is in operation win10. If you are, then all the way down the default installation directly to the next step. Screenshot installation steps in order not to eliminating the need for distracting. If you are the other system, you can download the corresponding version, Git commands are the same, without prejudice to upgrade Daguai together.

 Right, open Git Bash here, cmd window pop up a similar thing, it shows Git successfully installed it!

2. Register github account, of course, you can also use the code cloud. https://github.com

3. In the git bash in yourself first, tell Git your github username and mailbox. Open git, enter the following command:       

git config --global user.name  Your Name

git config --global user.email  [email protected]

Note: Your Name and [email protected] is to use the registration name and email above. -Global use of this parameter is to allow all machines Git repository use the user name and mailbox, different warehouses can also use a different user name and mailbox. But we usually only use a GitHub account, you can set it so directly.


3. How to create a local repository that?

Warehouse (Repository) can be simply understood as a directory, each directory contains a warehouse. We can create their own computer anywhere in a folder (for example, F: / study / studyGit), we want to build a warehouse, called learngit. Open Git Bash, cd to F: / under study / studyGit directory, create a new directory learngit, then to learngit cd directory command is as follows:

Use the following command will become learngit directory can manage Git repository:

.Git generate a hidden folder, represents a successful initialization under learngit directory, the directory has been Git can manage. Then add some things to the warehouse.

step1 : Create a readme.txt.

     # Git add command tells Git, add files to the repository;

 step2git add readme.txt    

     # Git commit command tells Git, the submission of documents to the warehouse;

 step3git commit -m doc: create readme file 

 Note : Enter -m behind this explanation is submitted for your convenience from the history list easy to find change records, please write meaningful point. If you have multiple files, you can use git add to add in all of the files, and finally once git commit command just fine. It is worth mentioning that you can also use git add. Directly to all the files in this directory are added in one warehouse to warehouse, a lot easier.


4. remote repository

Remote repository is one of Git's killer feature.

step1 : Create a SSH Key. In the user's home directory to see if there .ssh directory, if there is, and then see if there id_rsa and id_rsa.pub these two files in this directory, if you already have, you can jump directly to the next step. If not, open a terminal (open Git Bash under Windows), create SSH Key:

     ssh-keygen -t rsa -C  [email protected]

Enter 3 times in a row can be friends. Here you will find two files

step2 : Copy the contents of the above pub this document, click on the SSH keys:

Click the Add SSH key, to complete the SSH configuration. The reason for setting SSH key, in order to identify you push really push you, not someone else posing, and Git support SSH, so, GitHub just know that your public key, you can confirm that only you can push.

Note: If you have a computer at home and companies. It can put the two computers are added to your public GitHub, so you can achieve a push.


5. The local repository to push Github

step1 : New Warehouse

 

 

Then, Repository name written on learnGit, do not check "Initialize this repository with a README", click on Create repository.

The next screen is:

 Click on the red box button to copy the address of the remote repository learnGit.

step2 : In our Git Bash interface, the local Git repository associated with the remote warehouse just built, enter the following command: git the Add Remote Origin https://github.com/yourname/learngit.git

Careful friend found the second of the matter is that the picture above. Yourname put into your ha.

step3 : push to a remote repository

 

Back to GitHub, go learnGit warehouse, you will find the readme.txt file has been reached on our GitHub of. GitHub page to see the contents of remote and local databases have been exactly the same as.

Note that after any changes, can be carried out in three steps:

  1. git add .

  2. git commit -m xxx

  3. git push -u origin master

After the general input "git push -u origin master" statements, GitHub need to enter a user name and password. This is because we are using the https presented in a way, you can change the way ssh. Once connected directly after git push.


On 6.Github cloning project to a local warehouse

step1: Copy the address of the warehouse

step2: Open Git Bash, cd to establish between our F: / study / studyGit

step3: Enter git clone https://github.com/yourname/learngit.git, you can directly remote repository GitHub to clone local learngit

After performing step3, it will create a directory called learngit in the current directory, which contains a .git directory for saving all versions of records downloaded;

Note: This completes the clone from a remote repository to the local repository GitHub function, this method does not run git init statement, a statement can be directly above.

After any changes, can be carried out in three steps above.

Less than 10 minutes to complete, quickly practice up! So that we can put their project into git, first began the first step, and then it stabilized it, then we will learn some of the solutions listed Git commands must know and often the case, and the play has come! Please learn it along to White CV.

Past Events

1. --- frequently asked questions of the interview adopted piecemeal

2. FAQ's C ++ Interview 1--10

3. FAQ's C ++ Interview 11--20

4. Autumn strokes written resume, a greater chance to take the offer oh (Bonus resume template)

5. FREE! Free shipping! More than 30 technology books for free delivery, great feedback Mid-Autumn Festival

White CV: No. designed to focus public CV (computer vision), AI (artificial intelligence) technology-related fields, the main content of the article around the C ++, Python programming techniques, machine learning (ML), the depth of learning (DL), OpenCV image processing, etc. technology, explore the depth of technical points, study and work record common operations, problems do you learn to work assistant. Only concerned with technology, the professional knowledge sharing platform CV field.
----------------

 

Published 74 original articles · won praise 64 · views 130 000 +

Guess you like

Origin blog.csdn.net/wsLJQian/article/details/102963207