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

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请求!

👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏

👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏

Now, go ahead and send me that DevJoke!

现在,继续发送DevJoke给我!



Did you learn something new? Have comments? Know a DevJoke? Tweet me @shrutikapoor08

你学到新东西了吗? 有意见吗? 知道开发笑话吗? 鸣叫我@ shrutikapoor08

翻译自: https://www.freecodecamp.org/news/git-101-git-workflow-to-get-you-started-pushing-code/

git 代码推送流程

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391379.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

多元时间序列回归模型_多元时间序列分析和预测:将向量自回归(VAR)模型应用于实际的多元数据集...

多元时间序列回归模型Multivariate Time Series Analysis多元时间序列分析 A univariate time series data contains only one single time-dependent variable while a multivariate time series data consists of multiple time-dependent variables. We generally use mult…

字符串基本操作

1.已知‘星期一星期二星期三星期四星期五星期六星期日 ’&#xff0c;输入数字&#xff08;1-7&#xff09;&#xff0c;输出相应的‘星期几 s星期一星期二星期三星期四星期五星期六星期日 d int(input(输入1-7:)) print(s[3*(d-1):3*d]) 2.输入学号&#xff0c;识别年级、专业…

linux:使用python脚本监控某个进程是否存在(不使用crontab)

背景&#xff1a; 需要每天定时去检测crontab进程是否启动&#xff0c;所以不能用crontab来启动检测脚本了&#xff0c;直接使用while 循环和sleep方式实现定时检测 # coding:utf-8 import os import send_message import datetime import timecurr_time datetime.datetime.no…

Go语言实战 : API服务器 (1) 技术选型

1. API是什么&#xff1f; API&#xff08;Application Programming Interface&#xff0c;应用程序编程接口&#xff09;是一些预先定义的函数或者接口&#xff0c;目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力&#xff0c;而又无须访问源码&#xf…

天猫客户端组件动态化方案——VirtualView 工具大更新

前文《天猫客户端组件动态化的方案——VirtualView 上手体验》都提到了自定义模板编译成二进制数据的过程&#xff0c;在 Android 版的 Playground 里内置了一个编译工具可以实时调测&#xff0c;然而业务开发过程中&#xff0c;不可能在手机上编译&#xff0c;而是在电脑或者后…

tableau可视化_如何在Tableau中构建自定义地图可视化

tableau可视化Sometime last year, I got fascinated with bubble charts when I saw a data visualization video, Hans Roslings 200 Countries, 200 Years, 4 Minutes - The Joy of Stats from BBC.去年的某个时候&#xff0c;当我看到一个数据可视化视频时&#xff0c;我迷…

数据分析和大数据哪个更吃香_处理数据,大数据甚至更大数据的17种策略

数据分析和大数据哪个更吃香Dealing with big data can be tricky. No one likes out of memory errors. ☹️ No one likes waiting for code to run. ⏳ No one likes leaving Python. &#x1f40d;处理大数据可能很棘手。 没有人喜欢内存不足错误。 No️没有人喜欢等待代码…

MySQL 数据还原

1.1还原使用mysqldump命令备份的数据库的语法如下&#xff1a; mysql -u root -p [dbname] < backup.sq 示例&#xff1a; mysql -u root -p < C:\backup.sql 1.2还原直接复制目录的备份 通过这种方式还原时&#xff0c;必须保证两个MySQL数据库的版本号是相同的。MyISAM…

test6

test6 转载于:https://www.cnblogs.com/Forever77/p/11474320.html

VueJs学习入门指引

新产品开发决定要用到vuejs&#xff0c;总结一个vuejs学习指引。 1.安装一个Node环境 去Nodejs官网下载windows版本node 下载地址&#xff1a; https://nodejs.org/zh-cn/ 2.使用node的npm工具搭建一个Vue项目&#xff0c;这里混合进入了ElementUI 搭建指引地址: https:…

粒子网格算法 pm_使粒子网格与Blynk一起使用的2种最佳方法

粒子网格算法 pmThis post is originally from my blog on www.jaredwolff.com.这篇文章最初来自我在www.jaredwolff.com上的博客。 Writing an app takes time. It takes even more time to write one that works with hardware.编写应用程序需要时间。 编写与硬件兼容的代码…

python:对list去重

1、set()方法 numbers [1,7,3,2,5,6,2,3,4,1,5] new_numbers list(set(numbers)) print new_numbers 输出 [1, 2, 3, 4, 5, 6, 7] 特点&#xff1a;不保证原有顺序 2、原始方法 numbers [1,7,3,2,5,6,2,3,4,1,5] new_numbers [] for x in numbers:if x not in new_numbers:…

运维工程师如果将web服务http专变为https

1&#xff1a;生成私钥 2&#xff1a;生成证书签署请求 3&#xff1a;在提供CA签署的web网站上&#xff0c;提交生成的证书签署请求 4&#xff1a;下载已经签署的CA证书 5&#xff1a;将证书的信息保留在web服务器中&#xff0c;且应用到提供web服务的软件即可转载于:https://w…

leetcode 363. 矩形区域不超过 K 的最大数值和

给你一个 m x n 的矩阵 matrix 和一个整数 k &#xff0c;找出并返回矩阵内部矩形区域的不超过 k 的最大数值和。 题目数据保证总会存在一个数值和不超过 k 的矩形区域。 示例 1&#xff1a; 输入&#xff1a;matrix [[1,0,1],[0,-2,3]], k 2 输出&#xff1a;2 解释&…

centos7.4二进制安装mysql

1&#xff1a;下载二进制安装包&#xff08;安装时确保没有mysql数据库服务器端&#xff09;&#xff1a; mariadb-10.2.12-linux-x86_64.tar.gz、 mariadb-10.2.12.tar.gz。2&#xff1a;创建系统账号指定shell类型&#xff08;默认自动创建同名的组&#xff09;3&#xff1a;…

批梯度下降 随机梯度下降_梯度下降及其变体快速指南

批梯度下降 随机梯度下降In this article, I am going to discuss the Gradient Descent algorithm. The next article will be in continuation of this article where I will discuss optimizers in neural networks. For understanding those optimizers it’s important to…

java作业 2.6

//程序猿&#xff1a;孔宏旭 2017.X.XX /**功能&#xff1a;在键盘输入一个三位数&#xff0c;求它们的各数位之和。 *1、使用Scanner关键字来实现从键盘输入的方法。 *2、使用取余的方法将各个数位提取出来。 *3、最后将得到的各个数位相加。 */ import java.util.Scanner; p…

ubuntu 16.04 挂载新硬盘

2、挂载数据盘 mkdir /datausrubuntu:~$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disk sda1 8:1 0 512M 0 part /boot/efisda2 8:2 0 464.3G 0 part /sda3 8:3 0 976…

Go语言实战 : API服务器 (2) 运行流程

1.API服务器的总流程 分为两步&#xff1a; 启动API服务器API服务器对HTTP请求进行处理 2.API服务器启动流程 解析配置文件&#xff0c;利用配置文件完成对服务器的初始化配置初始化logger&#xff0c;开启日志记录与数据库建立连接设置http连接&#xff08;例如设置响应头…

Linux 命令 之查看程序占用内存

2019独角兽企业重金招聘Python工程师标准>>> 查看PID ps aux | grep nginx root 3531 0.0 0.0 18404 832 ? Ss 15:29 0:00 nginx: master process ./nginx 查看占用资源情况 pmap -d 3531 top -p 3531 转载于:https://my.oschina.net/mengzha…