git 代码推送流程

I'm going to explain Git the way I wish someone had explained to me back when I was first learning.

我将以我希望有人在我第一次学习时向我解释的方式来解释Git。

I'll show how you can get started with just a few commands, and the concepts at work behind those concepts.

我将展示您如何仅需几个命令就可以开始使用,以及这些概念背后的概念。

基本概念 (Basic concepts)

您的本地代码 (Your local code)

This is the work that you do on your computer. Any edits, formats, features or development work that you have in your computer is your local code.

这是您在计算机上所做的工作。 您在计算机中进行的任何编辑,格式,功能或开发工作都是您的本地代码。

上演网站 (Staged site)

Once you are happy with the changes or amount of work done, you can mark it as ready for stage. It means that you are declaring that these lines of code are ready to be committed.

一旦对更改或完成的工作感到满意,就可以将其标记为准备就绪。 这意味着您要声明这些代码行已准备好提交。

服务器 (The server)

Once you are feel ready with the files you have staged, you can send them out to the server which stores all your code so that other people can use it too. Now your files can be viewed by other people and be worked on.

一旦准备好暂存的文件,就可以将它们发送到存储所有代码的服务器,以便其他人也可以使用它。 现在,您的文件可以被其他人查看并进行处理。

最终目标 (The end goal)

The idea behind git is that your code on the remote server should be synced with the code on your machine. When you work with other folks, their code should be synced with your code. So if your co-workers pushed new code, you should be able to easily update your code to reflect their changes.

git的想法是,应该将远程服务器上的代码与计算机上的代码同步。 当您与其他人一起工作时,他们的代码应与您的代码同步。 因此,如果您的同事推送了新代码,则您应该能够轻松地更新代码以反映他们的更改。

The end of goal is that everything on the server should be the same as everything on your local machine. You should send files to the server as soon as possible so that when others view your code, they have the most updated version.

目标的最后是服务器上的所有内容都应与本地计算机上的所有内容相同。 您应该尽快将文件发送到服务器,以便其他人查看您的代码时,它们具有最新版本。

工作流程 (Workflow)

Let’s say you have a folder on your computer where you have your code. You want to put it in GitHub so you can version control it.

假设您在计算机上有一个存放代码的文件夹。 您希望将其放在GitHub中,以便可以对其进行版本控制。

Here’s how you can do it.

这是您的操作方法。

1.获取存储库。 (1. Getting a repository.)

There’s two ways of getting a repository — either you can create one of your own, or you can work off of someone’s repository and contribute to their repository. Which one you choose depends on the project you are working on. If you are working on a project by yourself, you are more likely to create a repository from scratch and start writing code. When you work on open source code or working in a team, you will most likely get a repository that already exists. Let’s talk about how to do both —

获取存储库有两种方法-您可以创建自己的存储库,也可以在某人的存储库中工作并为他们的存储库做出贡献。 选择哪一个取决于您正在处理的项目。 如果您是一个人从事项目,则更有可能从头开始创建存储库并开始编写代码。 当您使用开源代码或团队合作时,很可能会获得一个已经存在的存储库。 让我们来谈谈两者的做法

创建一个仓库 (Create a Repository)

First you will need to create a GitHub account if you don’t already have one. Click on Repositories tab and click “New”

首先,如果您还没有一个GitHub帐户,则需要创建一个。 单击存储库选项卡,然后单击“新建”

Follow instructions to create your new repository. Let’s say we name this repository test-repo . Once you have created this repo, GitHub gives instruction on how to set it up on your local computer.

按照说明创建新的存储库。 假设我们将此存储库命名为test-repo 。 创建此存储库后,GitHub会提供有关如何在本地计算机上进行设置的说明。

Use the instructions to create a new repository on the command line -

使用说明在命令行上创建新的存储库-

克隆存储库 (Cloning a repository)

git clone <repository>

git clone <repository>

Let’s say you want to get the code I am working on so you can work off of it on your computer. You will need to find my github account and clone a repository that you are interested in. Today we are going to work on this repository —

假设您要获取我正在使用的代码,以便可以在计算机上使用它。 您将需要找到我的github帐户并克隆一个您感兴趣的存储库。今天,我们将在该存储库上进行工作-

git clone git@github.com:shrutikapoor08/devjoke.git

2.创建一个分支 (
2. Create a branch)

Creating a branch helps to keep work in progress separate from a working piece of code. It also helps you modularize your code and keep features separate while you are still working on them. Let’s make a new branch joke-branch by using

创建分支有助于使工作与代码段分开进行。 它还可以帮助您模块化代码,并在使用功能时将其分开。 让我们通过使用一个新的分支joke-branch

git checkout -b joke-branch

git checkout -b joke-branch

You can push this branch to the server (origin)by —

您可以通过以下方式将此分支推送到服务器( origin ):

git push origin joke-branch

git push origin joke-branch

Now let’s assume that you and I are teammates. We are working on a project together. Let’s walk through the workflow.

现在,假设您和我是队友。 我们正在共同致力于一个项目。 让我们来看一下工作流程。

3.修改代码 (3. Modifying code)

Once you understand what the code does, you are ready to make edits. If you are working on somebody else’s repository, it is a good idea to make a forkof their repository. “Forking” is making a copy of a repository. It is like running a repository through a copy machine and getting your own copy. You can do whatever you want to your copy, make changes, edit files, delete files or add new files. If you want, you can send your updates to the original repository and ask for your code to get merged into the original repository.

一旦了解了代码的功能,就可以进行编辑了。 如果您正在使用其他人的存储库,则最好将他们的存储库作为fork 。 “分叉”正在复制存储库。 就像通过复制机运行存储库并获取自己的副本一样。 您可以对副本执行任何操作,进行更改,编辑文件,删除文件或添加新文件。 如果需要,可以将更新发送到原始存储库,并要求您的代码合并到原始存储库中。

We are going to be modifying this code by creating a fork of this repository. To fork a repository, click on the Fork button at the top of the repository.

我们将通过创建此存储库的派生来修改此代码。 要派生存储库,请单击存储库顶部的“分叉”按钮。

Now if you go to your Github profile, you can see your newly created fork repository in your profile. Woot Woot!

现在,如果您转到Github个人资料,则可以在个人资料中看到新创建的fork存储库。 呜呜!

Now we are going to make some changes. Open the README.mdfile. To this file, we are going to add a DevJoke!  Think of a clever programming joke and add it to the top of this file. Here is a #DevJoke for you — 

现在,我们将进行一些更改。 打开README.md文件。 在这个文件中,我们将添加一个DevJoke! 考虑一个聪明的编程笑话,并将其添加到此文件的顶部。 这是给您的#DevJoke-

Why do Java programmers wear glasses?

为什么Java程序员戴眼镜?

.

.

.

.

4.提交代码 (4. Committing code)

Now, let’s save and commit this file. If you are committing a newly created file, you will first have to add it to your stage. You can do so by — 

现在,让我们保存并提交该文件。 如果要提交新创建的文件,则首先必须将其添加到舞台。 您可以通过-

git add <filename>

git add <filename>

Once your file is staged, you can commit. Be sure to append your commit with a message that will help you remember in the future what this commit is about.

暂存文件后,即可提交。 确保在提交后附加一条消息,以帮助您将来记住该提交的含义。

git commit -m "Adding DevJoke about C#

git commit -m "Adding DevJoke about C#

5.推送代码 (5. Pushing code)

Remember, when you are working on a repository that other people are also working on, it is possible that while you were working on your local version, some people may have pushed code. So now the server is “one step ahead of you”. You now need to sync your computer to the server to make sure you have the most updated code. To do so, you can pull from the server —

请记住,当您在其他人也正在使用的存储库上工作时,当您在本地版本上工作时,可能会有一些人推送了代码。 因此,现在服务器“比您领先一步”。 现在,您需要将计算机同步到服务器,以确保您具有最新的代码。 为此,您可以从服务器中拉出-

git pull origin <branch-name>

git pull origin <branch-name>

If you have never made a branch, don’t worry. Git gives you master branch by default. You can also make a new branch by —

如果您从未建立过分支,请不要担心。 Git默认为您提供master分支。 您还可以通过以下方式建立新分支:

git checkout -b <branch-name>

Now that you have committed your code and your local machine is updated from server, you are ready to push your changes for the world to see. To push to branch master, you can do so by — git push origin master

现在,您已经提交了代码,并且本地服务器已从服务器更新,您可以将所做的更改推送给全世界。 要推送到分支master ,可以通过以下方式进行操作:git push origin master

YAYY!!! You made your first push! Give yourself a pat on the back. That was the hard part. Now you are ready to commit your ass off.

呀! 您是第一个推动者! 拍拍自己的背部。 那是困难的部分。 现在,您可以准备放弃了。

6.发出拉取请求 (6. Making a Pull Request)

Now, send me that wonderful #DevJoke of yours by creating a pull request. Pull request is a feature by which you — the developer, requests me — the code owner to merge your code into the repository. Creating a pull request is easy. Go to github.com and open the repository you have been working on.

现在,通过创建拉取请求,将您的精彩的#DevJoke发送给我。 拉请求是一项功能,您(开发人员可以向我索取)代码所有者将您的代码合并到存储库中。 创建拉取请求很容易。 转到github.com并打开您一直在使用的存储库。

You will see a Pull request button like this :

您将看到如下所示的“拉取”请求按钮:

Click the button and follow the instructions to create a pull request. Make sure your changes are correctly reflected on the “Comparing changes” screen.

单击按钮,然后按照说明创建拉取请求。 确保您的更改正确显示在“比较更改”屏幕上。

Click on “Create pull request” and that’s it! You are done! You successfully made your first Pull request!

单击“创建请求请求”,仅此而已! 大功告成! 您已成功发出第一个Pull请求!

git 代码推送流程_Git 101:一个让您开始推送代码的Git工作流程相关推荐

  1. Git之深入解析如何使用Git的分布式工作流程与如何管理多人开发贡献的项目

    一.分布式工作流程 如果现在拥有一个远程 Git 版本库,就能为所有开发者共享代码提供服务:在一个本地工作流程下,如果你也已经熟悉了基本 Git 命令,现在就可以学习如何利用 Git 提供的一些分布式 ...

  2. Git多人协作工作流程

    前言 之前一直把Git当做个人版本控制的工具使用,现在由于工作需要,需要多人协作维护文档,所以去简单了解了下Git多人协作的工作流程,发现还真的很多讲解的,而且大神也已经讲解得很清楚了,这里就做一个简 ...

  3. Git 学习笔记:5 分布式工作流程

    Git 学习笔记:5 分布式工作流程 分布式工作流程 集中式工作流 集成管理员工作流 司令官与副官工作流 工作流程总结 向一个项目贡献 提交准则 私有小型团队 John's Machine 私有管理团 ...

  4. git 拉取远端仓库_git命令-远程仓库拉取、本地仓库更新、工作空间提交等等

    一,新建代码库 1,在当前目录下新建一个git代码库 $ git init 2,新建一个目录将其初始化为git代码库 $ git init [project-name] 3,git clone 远程代 ...

  5. 小程序工程化实践(上篇)-- 手把手教你撸一个小程序 webpack 插件,一个例子带你熟悉 webpack 工作流程...

    本文基于 webpack 4 和 babel 7,Mac OS,VS Code 小程序开发现状: 小程序开发者工具不好用,官方对 npm 的支持有限,缺少对 webpack, babel 等前端常用工 ...

  6. Gitflow工作流程

    在工作场合实施Git的时候,有很多种工作流程可供选择,此时反而会让你手足无措.本文罗列了企业团队最常用的一些git工作流程,包括Centralized Workflow.Feature Branch ...

  7. 人工智能开发人员工作流程、看法、工具统计数据

    人工智能开发人员工作流程.看法.工具统计数据 本文目录: 一.人工智能开发所需要的技能和知识 二.开发人工智能需要以下工具 2.1.开发过程中的人工智能工具调查 2.2.AI 工具情绪调查 2.3.A ...

  8. 大数据分析工作流程是什么

    大数据分析工作流程是什么?高效的工作流应该做到这一点-流程化-将我们从项目的每个阶段无缝地引导到下一个阶段,优化任务管理,并最终指导我们从业务问题到解决方案再到价值.随着数据泛滥的持续减少,企业正在淹 ...

  9. 图解 Deployment Controller 工作流程

    本文基于对 Kubernetes v1.16 的源码阅读,通过流程图描述 Deployment Controller 的工作流程,但也包含相关代码以供参考. 上一篇文章<Kubernetes C ...

最新文章

  1. redis 生成dump.rdb文件
  2. 个性化邮件系统用例设计和实现
  3. SMW0上传文件到数据库层详解
  4. Maven拉取私服Jar包和发布jar包到maven私服
  5. python计算长方体体积编程_计算体积 编程创建一个Box类(长方体) 联合开发网 - pudn.com...
  6. nginx main error_page
  7. PowerShell 在 SharePoint 2010 自动化部署中的应用(2)-编译打包
  8. Linux的tasklet函数详解
  9. Python学习笔记之 函数基础,pass
  10. js中运算符的优先级
  11. 五十款阿里开源软件说明介绍
  12. 如何像专业人士一样使用 Google 学术搜索
  13. [大学物理实验-4]弦上驻波实验
  14. android辅助功能demo,Android中的辅助功能实现问题
  15. 计算机夏令营英语面试,2016北航计算机夏令营的经验
  16. python - TypeError: combat(sume,sumu) missing 2 required positional arguments: sume,sumu
  17. 一篇文章扫盲手机SIM卡相关知识
  18. python里的self
  19. Python获取pi值的五种方法
  20. C++生成条型码和二维码源码及调用示例 还是C#方便

热门文章

  1. web开发课程,HTML常用的五种标签,附赠课程+题库
  2. Codeforces- Educational Codeforces Round 69
  3. python接口自动化(四)--接口测试工具介绍(详解)
  4. 三十四 Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解
  5. CCF-CSP 最大的矩形
  6. Head First summary
  7. C#中打开设计视图时报未将对象引用设置到对象的实例
  8. VS2005中ReportViewer 本地模式下报表呈现 入门示例
  9. 锁表的进程和语句,并杀掉
  10. IS环境下配置PHP5+MySql+PHPMyAdmin