码迷,mamicode.com
首页 > 其他好文 > 详细

How to Manage your GIT Repository Tutorial

时间:2020-01-11 13:21:31      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:access   ade   one   ble   lin   existing   github   help   load   

GIT Repository Management

This tutorial explains how to use GIT to create a project, add files, commit modifications and upload them in the remote repository at GitHub.

First, you should generate an SSH key. You must have at least one SSH public key to push your git repository to GitHub.

You can check our knowledgebase articles how to generate an SSH key in WindowsMAC OS and Linux.

Next, you should add the key through the GitHub interface. This is done by accessing the Settings page for your account -> SSH and GPG Keys section. On that page, click the New SSH key button.

技术图片

A new panel will appear in which you should input a Title for the key and the private key itself. Once done, press the Add SSH key button.

技术图片

Then, open a new Terminal window on your computer. First you should create a new folder in which to develop and manage the repository. This can be done with the following command:

This will create a folder named GIT in the current working directory. Access that folder with:

Then initialize a new GIT repository with:

You should create files and folders for your GIT repository. For example, you can create a README file with the following command:

This will create an empty file named README in the GIT repository folder. However this does not automatically add the file to the GIT repo. You can compare the list of files in the actual GIT repository and the list of current files you have created with:

The above shows that you have a file named README that is present in the folder, but is not added to GIT repository. So now, you need to add the file to the GIT repository index. This can be done with:

Then, you can compare again the list of files in the actual GIT repository and the list of current files you have created:

The file is now added to the repo index and you need to commit it. By committing a file, you add it to the actual repository. Committing is used when you create new files or modify existing ones and want to "push" your changes to the repository. To commit the README file, you can use the following command:

where "-m ‘first commit‘" is a comment which is left in the repository history. Using commits you can describe the changes which are made to the repository files, which will help you better to follow the development of your project.

Now,  if you check the status of the git repository, you will see there are no new changes to commit.

All of these changes were done to a local repository on your machine. If you want to push them to the remote GIT repo you have at GitHub, you first need to add the repo on your machine with:

Make sure to replace your_username and name_of_your_repo with your actual GitHub username and the name of your repository. The command will "link" the two repositories, so any changes made to the local one can be pushed to the remote one at GitHub.

To push the changes to the GitHub repository now, you can use this command:

Now, if you access the GitHub repository, you will see the README file there.

How to Manage your GIT Repository Tutorial

标签:access   ade   one   ble   lin   existing   github   help   load   

原文地址:https://www.cnblogs.com/karmapeng/p/12179425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!