git基础入门_git基础入门第一部分

git基础入门

从头开始学习软件开发—协作系列 (Learning Software Development From Scratch — Collaboration Series)

We know in this world how technology is used and everywhere we go, we are indulged with it. Starting from the coffee machine to get things done at work. Have you ever wondered, how this is all happening, what is happening in the world how are we able to find apps for every utility of our life from playing games to measuring your heartbeat? We are not gonna talk about how they develop that software, but we are gonna learn what they use to develop, build, and scale in larger teams. Of course, this is not a one-man job unless you are Justin Long, form the Die Hard 4.

我们知道在这个世界上技术是如何使用的,无论我们走到哪里,我们都沉迷于技术。 从咖啡机开始工作。 您是否曾经想过,这是怎么回事,世界上是怎么回事,我们如何才能找到适合生活中各种用途的应用程序,从玩游戏到测量心跳? 我们不会谈论他们如何开发该软件,而是会了解他们在更大的团队中开发,构建和扩展产品的用途。 当然,除非您是贾斯汀·朗,否则这不是单身工作 虎胆龙威4。

These organizations of some amazing individuals called developers, collaborate to build the apps that help us to lead our life easier. To do this they need a central repository where they can keep track of files and scripts that they code. All versioning, tracking files, branches, and other environment-dependent tasks are stored in one system. To manage the code base and perform development actions we have mainly 2 systems, Git and Team Foundation Version Control/System (TFVC/TFVS)

这些由一些叫开发人员的出色个人组成的组织合作开发了可帮助我们更轻松地生活的应用程序。 为此,他们需要一个中央存储库,在其中可以跟踪其编写的文件和脚本。 所有版本控制,跟踪文件,分支和其他与环境有关的任务都存储在一个系统中。 为了管理代码库并执行开发操作,我们主要有2个系统, GitTeam Foundation版本控制/系统(TFVC / TFVS)

Git is a free, distributed version control system that allows programmers to keep track of code changes.

Git是一个免费的分布式版本控制系统,它使程序员可以跟踪代码更改。

Git Repository: Utilizing commits allows programmers to test, debug, and create new features collaboratively. All commits are kept in what is known as a “Git Repository” that can be hosted on your computer, private servers, or open-source websites, such as GitHub. GitHub provides cloud services using Git.

Git存储库:利用提交,程序员可以协同测试,调试和创建新功能。 所有提交都保存在所谓的“ Git存储库 ”中,该存储库可以托管在您的计算机,私有服务器或开源网站(例如GitHub)上。 GitHub使用Git提供云服务。

Git Bash: Git Bash is a package that installs Bash, some common bash utilities and it includes the full set of Git core commands.

Git Bash: Git Bash是一个安装Bash的程序包,它是一些常见的bash实用程序,并且包含完整的Git核心命令集。

Git has 3 different areas for your code:

Git有3个不同的代码区域:

  • Working directory: The area that you will be doing all your work in (creating, editing, deleting, and organizing files)

    工作目录 :您将在其中进行所有工作(创建,编辑,删除和组织文件)的区域

  • Staging area: The area where you will list the changes that you have made to the working directory

    暂存区域 :您将在其中列出对工作目录所做的更改的区域

  • Repository: Where Git permanently stores the changes, you have made as different versions of the project.

    仓库 :Git永久存储更改的位置,您已将其作为项目的不同版本进行。

Git和GitHub之间的区别: (Difference between Git and GitHub:)

Image for post

Git is a distributed version control system that tracks changes to source code over time. Git can work without GitHub as other web-based Git repositories are also available. It stores and catalog changes in code in a repository. It is installed on the local system.

Git是一个分布式版本控制系统,可以跟踪源代码随时间的变化。 Git可以在没有GitHub的情况下工作,因为其他基于Web的Git存储库也可用。 它将更改的代码存储和分类到存储库中。 它安装在本地系统上。

GitHub is a web-based hosting service for Git repository to bring teams together.GitHub is the most popular git server but there are other alternatives available such as GitLab and Bit Bucket. It provides a platform as a collaborative effort to bring teams together. It is hosted on the web.

GitHub是用于Git存储库的基于Web的托管服务,可将团队聚集在一起。GitHub是最受欢迎的git服务器,但还有其他可用的替代方法,例如GitLab和Bit Bucket。 它提供了一个平台,将团队团结在一起。 它托管在网络上。

什么是GitHub? (What is GitHub?)

Now to explain how Git works, I am going to explain to you how to create a Git repository and syncing it with our local computer. We will also learn how to do modifications in the file and how this will be synced to an online repository that is present in GitHub. GitHub is a development platform that hosts the Git repository to help us develop software/apps.

现在解释Git的工作原理,我将向您解释如何创建Git存储库并将其与我们的本地计算机同步。 我们还将学习如何在文件中进行修改,以及如何将其同步到GitHub中存在的在线存储库。 GitHub是一个托管Git存储库的开发平台,可帮助我们开发软件/应用程序。

Prerequisites:

先决条件:

  1. Installing git in your local machine. To know how to install git in your local machine please visit https://git-scm.com/

    在本地计算机上安装git。 要知道如何在本地计算机上安装git,请访问https://git-scm.com/

  2. Command Line Interface

    命令行界面
  3. Stable Internet connection

    稳定的互联网连接
  4. GitHub Account (If you don’t have an account, you can create on in here, https://www.github.com)

    GitHub帐户(如果您没有帐户,则可以在此处https://www.github.com上创建)

Now, let’s move on to creating a repository in GitHub. After signing up, the GitHub home page opens, and you may need to verify your email address. After that go to github.com and the homepage will open. In the home page, you find a button to create a new repository at the left bar,

现在,让我们继续在GitHub中创建存储库。 注册后,将打开GitHub主页,您可能需要验证您的电子邮件地址。 之后,转到github.com,主页将打开。 在首页中,您会在左侧栏中找到一个用于创建新存储库的按钮,

Image for post
GitHub GitHub

创建一个新的存储库: (Create a new repository:)

  1. As the below picture is self-explanatory

    由于下图是不言自明的
  2. You can add the repository name and the description.

    您可以添加存储库名称和描述。
  3. You can find two options public and private. (refer below for details)

    您可以找到公共和私有两个选项。 (有关详情,请参阅下文)

  4. If you check the mark initialize this repository with a README file this initializes your repository with a README.md file which we discuss in the next section of this article.

    如果选中该标记,则使用README文件初始化此存储库,这将使用README.md文件初始化存储库,我们将在本文的下一部分中讨论该文件。

  5. You can select the Add .gitignore and license accordingly and create a repository. More about licensing will be discussed in further articles of this series.

    您可以选择添加.gitignore并相应地进行许可并创建存储库。 有关许可的更多信息将在本系列的其他文章中讨论。

  6. After creating the repository, a README.md file will be generated in the repository and henceforth, your online repository is ready and it is the time to create an offline repository in your local system and connect It to the newly created repository in GitHub.

    创建存储库后,将在存储库中生成README.md文件,此后,您的在线存储库已准备就绪,现在该在本地系统中创建脱机存储库并将其连接到GitHub中新创建的存储库的时候了。

  7. For that, you need to create a folder in your machine.

    为此,您需要在计算机中创建一个文件夹。
  8. Open command-line interface and change directory to the folder which you newly created. (You can open command line directly typing cmd in your address bar or in Mac go o Terminal and point to the folder you created in the last step)

    打开命令行界面,然后将目录更改为新创建的文件夹。 (您可以 在地址栏中或在Mac go o终端中 直接键入 cmd 来打开命令行, 并指向您在上一步中创建的文件夹)

Image for post
GitHub GitHub
  • Public — Anyone on the internet can see this repository. You choose who can commit or make changes

    公开 -互联网上的任何人都可以看到此存储库。 您选择谁可以提交或进行更改

  • Private — You choose who can see and commit to this repository.

    私人 -选择可以查看并提交到此存储库的人。

在本地系统中初始化存储库: (Initializing Repository in your local system:)

  • Now it is time for us to create an empty repository in our machine. So, to create an empty repository, we need to use git command in CLI (Command Line Interface)

    现在是时候在我们的机器上创建一个空的存储库了。 因此,要创建一个空的存储库,我们需要在CLI(命令行界面)中使用git命令
$ git init
  • This will initialize the repository in your local system. In the hidden files if you see there is a folder created with the name .git and this is the folder where all the records will be stored. Your every code change is tracked in here. From this Git will understand where to connect and what to do and how to manage files.

    这将在本地系统中初始化存储库。 如果您在隐藏文件中看到一个名为.git的文件夹,则该文件夹将存储所有记录。 您的每个代码更改都在此处跟踪。 通过此工具,Git将了解在何处进行连接以及如何做以及如何管理文件。

(Make sure Git is installed in your system before creating Offline/Local repository)

(在创建离线/本地存储库之前,请确保系统中已安装Git)

将本地存储库连接到GitHub: (Connecting Local Repository to GitHub:)

  • To connect the repository in both local and online, we need to make use of git remote command. This will help us in setting up communication between them.

    要在本地和在线连接存储库,我们需要使用git remote命令。 这将帮助我们在它们之间建立通信。
  • After executing git init, run the below command.

    执行git init后,运行以下命令。
$ git remote add origin <URL of the repository>

(This is the command where we are telling git to connect to the remote server where the repository is there and add it to the local with the name origin. In here origin is just a variable name of the source URL that we are going to connect.)

(这是我们告诉git连接到存储库所在的远程服务器并将其添加到本地的命令,其名称为origin。在这里,origin只是我们要连接的源URL的变量名。 )

  • To get the URL of the repository in GitHub, you need to go to the repository that you have created online and then you should click on code and copy the URL as shown below.

    要获取GitHub中存储库的URL,您需要转到在线创建的存储库,然后单击代码并复制URL,如下所示。
Image for post
  • Once you execute the command, you are successfully connected to Git from your online and offline repository.

    一旦执行了命令,就可以从在线和离线存储库成功连接到Git。

So, now we are successful in creating Git repository and you connected to the online repository as well using git remote command.

因此,现在我们可以成功创建Git存储库,并且您也可以使用git remote命令连接到在线存储库。

In this part, we discussed what is Git and why it is used and also how to create a repository online and offline and connecting both.

在这一部分中,我们讨论了什么是Git以及为什么使用它,以及如何在线和离线创建存储库以及如何将两者连接。

In my next article, I will explain how to make changes in README.md file and how this is useful to document your software and the important steps. Also, we will discuss how to make code changes and push them to an online repository.

在我的下一篇文章中,我将解释如何在README.md文件中进行更改,以及这对记录软件和重要步骤的帮助。 此外,我们还将讨论如何进行代码更改并将其推送到在线存储库。

Until then Goodbye, Keep Learning and Keep reading. Don’t forget to contact me if you have any queries, sushmita@thenexteam.com

在此之前,再见,继续学习并继续阅读。 如有任何疑问, 联系我, sushmita @ thenexteam.com

翻译自: https://medium.com/the-next-team/introduction-to-git-basics-part-one-701fdf9cdb49

git基础入门

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值