qq营销软件:github_Github:从事软件开发工作需要了解的知识

qq营销软件:github

Github’s praises have been sung throughout the industry by developers far and wide. Entry level developers are either thrown to the wolves or just expected to know how to navigate this technology. Given the prevalence of Git, I thought it’d be fitting to give an overview of the inner workings.

Github的赞誉已在整个行业中广为流传。 入门级开发人员要么被狼吞虎咽,要么只是被期望知道如何驾驭这项技术。 考虑到Git的盛行,我认为概述一下内部工作是合适的。

Github is used for version control, but what does that mean? When you are working on a team with multiple developers, version control comes into play so that everyone’s work does not overlap and all of the code is saved.

Github用于版本控制,但这意味着什么? 当您与多个开发人员一起工作时,版本控制会发挥作用,这样每个人的工作就不会重叠,并且所有代码都将被保存。

I’ll use the example of a company website. The code for the website will likely be hosted on the company’s servers, but the most up to date code will also be on Github, serving as the master branch of its own repository. All of the developers that work on the website will have that code downloaded to run locally on their individual machines.

我将以公司网站为例。 该网站的代码可能会托管在公司的服务器上,但是最新的代码也将在Github上,作为自己存储库的主分支。 在该网站上工作的所有开发人员都将下载该代码,以在各自的计算机上本地运行。

Before you start making changes, a branch needs to be created to store the changes. The easiest explanation of what a branch is is to remember back to school when teachers used projectors. Notes were written with a marker on a clear sheet so the writing would be projected through the light and lens. A branch is basically placing a second clear sheet on top so that the original copy can be preserved.

在开始进行更改之前,需要创建一个分支来存储更改。 关于分支机构最简单的解释是当老师使用投影仪时要记得回到学校。 笔记是用记号笔在透明纸上书写的,因此笔迹将投射在光线和镜头上。 分支机构基本上是在顶部放置第二张透明纸,以便保留原始副本。

Branches can be created on Github itself, in the terminal, or in the code editor. Selecting the dropdown in a repo (shown below) can allow you to view all of the branches that have been created with the same master. If you do decide to create a branch through Github, you will need to ‘git pull’ that branch onto your computer before using the ‘git branch branchname’ command to switch to the designated branch. Another fun tip is that a branch does not need to be off of the master and can use another branch as its base.

可以在Github本身,终端或代码编辑器中创建分支。 选择回购中的下拉列表(如下所示)可以使您查看使用同一主数据库创建的所有分支。 如果您确实决定通过Github创建分支,则需要在使用“ git branch branchname ”命令切换到指定分支之前,将该分支“ git pull”到计算机上。 另一个有趣的提示是,分支不必脱离主节点,而可以使用另一个分支作为基础。

Image for post
Clicking on master to change branches
单击母版以更改分支

When the coding is done and everything is working correctly, you will want to push that up to Github. The command ‘git status’ will show all of the files that have been altered. The command ‘git add .’ will package all of the files that have been changed. There are chances that because you are running a website locally, some configuration files needed to be changed in order to run correctly. Those should not be uploaded to Github so you should individually add each file through ‘git add filepath’. A ‘git commit -m “message”’ should detail what the overall change was for, whether it be a bug fix or an added feature. The final command is ‘git push’ which will sent the entire package to Github.

编码完成并且一切正常后,您将需要将其推至Github。 命令“ git status”将显示所有已更改的文件。 命令“ git add”。 将打包所有已更改的文件。 由于您是在本地运行网站,因此有可能需要更改某些配置文件才能正常运行。 这些文件不应上传到Github,因此您应该通过'git add filepath '分别添加每个文件。 “ git commit -m“ 消息 ””应详细说明总体更改的目的,无论是错误修复还是附加功能。 最后的命令是'git push',它将把整个包发送到Github。

From there, you will create a pull request, or a “PR” for short. A pull request is a form that details the changes that are on the branch and gives a side by side comparison of your code and what appears in the master. Depending on the internal policies of the company, a number of your coworkers will review the code to make sure that nothing will break the master branch before it gets merged in.

从那里,您将创建一个拉取请求,或简称为“ PR”。 拉取请求是一种表格,其中详细说明了分支上的更改,并提供了代码与主代码中内容的并排比较。 根据公司的内部政策,您的许多同事将检查代码,以确保在合并主分支之前不会破坏主分支。

A good tip is that when coworkers are looking over your intended changes, the commit history will be visible. Because of this, a cleanly tracked history of your code is desirable with each commit implementing a separate portion. Going back to the website example, a commit history of “Implemented site shopping cart”, “Added shopping cart persistent history on page refresh”, and “Fixed shopping cart price bug after testing” allows others to see a clean progression of what you have worked on. A single commit of, “Implemented shopping cart”, is acceptable, but remains quite vague in your overall approach.

一个很好的提示是,当同事查看您的预期更改时,将显示提交历史记录。 因此,每次提交都实现一个单独的部分时,需要对代码进行清晰跟踪的历史记录。 回到网站示例,提交历史记录“已实施的站点购物车 ”,“ 在页面刷新中 添加了购物 车持久性历史记录 ”和“ 测试后固定的购物车价格错误 ”,其他人可以看到您所拥有的一切的清晰进展。从事。 一次提交“已实施的购物车 ”是可以接受的,但是在您的总体方法上仍然含糊不清。

It is quite cumbersome to push unfinished code while keeping in mind that your work will be scrutinized by peers. Cleaning up your history is something that only needs to done at the very end before writing up a pull request. Inside the terminal, the ‘git log’ command will show the history of commits that this branch has made. Identify which commit messages are not needed and how many commits ago it was made. If my previous commit was not needed, I can use the command ‘git reset HEAD~1". This will delete the previous commit made on this branch and add the files committed back into my changed files tree where I can ‘git add filepath’, git commit -m ‘message’, with git push -f’.

推送未完成的代码非常麻烦,同时要记住,您的工作将被同行审查。 清理历史记录只是在写请求请求之前最后要做的事情。 在终端内部,“ git log”命令将显示该分支进行的提交的历史记录。 确定不需要哪些提交消息以及之前进行了多少次提交。 如果不需要我先前的提交,则可以使用命令'git reset HEAD〜1“。这将删除该分支上的先前提交,并将提交的文件重新添加到更改后的文件树中,在这里我可以'git add filepath' , git commit -m'message '' git push -f '。

Version control comes into play after a new branch has been merged into the master. Any other developer that tries to push up code after your code has been merged into the master branch will get a merge conflict. This means that the master branch on Github is different from the master branch on their local computer and allowing the push would mean your changes get deleted when merged. They will need to rebase which means having to ‘git pull’ to update the changes to their local master branch, ‘git stash’ to store their current changes, ‘git fetch’ to update the branch with the latest changes, and ‘git stash apply’ to add back the changes that they had previous.

将新分支合并到主版本中后,版本控制才起作用。 将您的代码合并到master分支后,任何其他尝试推送代码的开发人员都会遇到合并冲突。 这意味着Github上的master分支不同于其本地计算机上的master分支,允许推送将意味着您的更改在合并时将被删除。 他们将需要重新设置基础,这意味着必须“ git pull”来将更改更新到其本地主分支,“ git stash”来存储其当前更改,“ git fetch”来使用最新更改来更新分支,以及“ git stash”应用”以添加他们之前所做的更改。

翻译自: https://medium.com/@vincentyangcsi/github-what-you-need-to-know-going-into-a-software-development-job-4c2a560e9c29

qq营销软件:github

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值