git 代理 git

by James Okunlade

詹姆斯·奥昆拉德(James Okunlade)

五分钟解释Git的要点 (The essentials of Git explained in five minutes)

As you learn to become a software developer, you’ll realize that most work is done in teams. And when you’re on a team, you’ll need a version control system to manage changes to your code base that come from different developers.

当您学习成为一名软件开发人员时,您会意识到大多数工作都是在团队中完成的。 在团队中时,您将需要一个版本控制系统来管理来自不同开发人员的代码库更改。

Git is one of the most popular version control systems. Yet, new developers can easily get overwhelmed when using it - I know I did. In fact, I avoided it for years.

Git是最流行的版本控制系统之一。 但是,新开发人员在使用它时很容易不知所措-我知道我做到了。 实际上,我避免了很多年。

If you’re a seasoned developer or don’t tremble at the mention of Git, feel free to skip to the next post. However, if you’re new to Git or not confident using it, take a few minutes to learn these basic - yet powerful - Git tips.

如果您是一位经验丰富的开发人员,或者不因提及Git而发抖,请随时跳到下一篇文章。 但是,如果您是Git的新手或不确定使用它,请花几分钟来学习这些基本但功能强大的Git技巧。

Here’s what we’ll cover:

这是我们要介绍的内容:

  1. Git cloneGit克隆
  2. Git checkoutGit结帐
  3. Git pullgit拉
  4. Git add and commitGit添加并提交
  5. Git stash and mergeGit隐藏并合并
  6. Git pushgit推

Git克隆 (Git clone)

Always clone new repositories you work on, which means downloading a copy of the repository files to your local computer. While there are many ways of cloning a repository, I will explain how to do it with the command line.

始终克隆您正在使用的新存储库,这意味着将存储库文件的副本下载到本地计算机。 尽管有很多克隆存储库的方法,但我将解释如何使用命令行来完成。

For example, if you want to clone the above repository, first copy the clone link above. Then, open your terminal, and cd to the location on your local computer where you want to put these files. Type git clone then paste the link as shown below if you want to clone the master branch.

例如,如果要克隆上述存储库,请首先复制上面的克隆链接。 然后,打开您的终端,并cd到您要在其中放置这些文件的本地计算机上的位置。 如果要克隆master分支,请键入git clone,然后粘贴如下所示的链接。

git clone https://github.com/JamesOkunlade/old-apple.git

git clone https://github.com/JamesOkunlade/old-apple.git

If you want to clone a particular branch of this repository, you’d want to do something like this:

如果要克隆此存储库的特定分支,则需要执行以下操作:

git clone https://github.com/JamesOkunlade/old-apple.git -b branch-name

git clone https://github.com/JamesOkunlade/old-apple.git -b branch-name

Git结帐 (Git checkout)

It’s a best practice to create different branches for different features instead of working on the master branch directly. When all features have been deemed to pass certain tests and requirements, then you can merge them into the master branch.

最佳做法是为不同的功能创建不同的分支,而不是直接在master分支上工作。 当所有功能都被认为通过了某些测试和要求后,您可以将它们合并到master分支中。

At different times, you will have to checkout to the particular repository branch you want to work on, and you can do this with the following command.

在不同的时间,您将不得不签出要处理的特定存储库分支,您可以使用以下命令来执行此操作。

If the branch had already been created:

如果分支已经创建:

git checkout branch-name

git checkout branch-name

And if you’re just creating the new feature branch:

如果您只是在创建新的功能分支,请执行以下操作:

git checkout -b branch-name

git checkout -b branch-name

git拉 (Git pull)

Your team or pair programming buddy will change different branches of a repository, and you should always pull these new changes before you start writing code. On your terminal, checkout to the branch you’ll be working on, and run the git pull command. The recent changes will be pulled to your local repository.

您的团队或结对编程的伙伴将更改存储库的不同分支,在开始编写代码之前,应始终提取这些新更改。 在终端上,签出要处理的分支,然后运行git pull命令。 最近的更改将被拉到您的本地存储库。

Git添加并提交 (Git add and commit)

The add and commit Git commands are almost always used together. Think of them as capture and save. You can’t save a thing if you don’t capture it first. Hence, the add command should always precede the commit command. While you use the add command to point at the particular file you want to capture in its current state, you use the commit to save a copy of what you captured.

add和commit Git命令几乎总是一起使用。 将它们视为捕获和保存。 如果不先捕获,就无法保存。 因此,add命令应始终在commit命令之前。 当您使用add命令指向要在其当前状态下捕获的特定文件时,您可以使用提交保存捕获内容的副本。

To capture all the files (except those excluded by Git ignore), you will use git add . and to capture the current state of a particular file, say index.html, you will have to type git add index.html

要捕获所有文件(Git忽略排除的文件除外),您将使用git add . 并捕获特定文件(例如index.html)的当前状态,则必须输入git add index.html

After taking the snapshots, you will then have to commit and save your snapshots to your local repository using the following:

拍摄快照之后,您将必须使用以下命令来提交快照并将其保存到本地存储库:

git commit -m ‘commit message’

git commit -m 'commit message'

The commit message should explain the peculiarity of the snapshot you’re saving. For example:

提交消息应说明您要保存的快照的特殊性。 例如:

git add index.html

git add index.html

git commit -m ‘the form feature button created’

git commit -m 'the form feature button created'

You can do the two together with the && operator as shown below;

您可以与&&运算符一起使用二者,如下所示;

git add index.html && git commit -m ‘footer html structure created’

git add index.html && git commit -m 'footer html structure created'

Git隐藏并合并 (Git stash and merge)

Simply doing git stash will stash whatever edit you have made to the branch but do not want to commit. That means when waiting on another developer to commit and push their copy of the code, you can experiment with some things in this same branch. Git encourages it. Whenever you’re ready to pull new changes to your local repository, but do not want to merge your own edits to it, you then have to stash your own edits. Git stash will keep the copy somewhere else for you and it’s accessible by doing Git stash list.

简单地执行git stash将隐藏您对分支所做的任何编辑,但不想提交。 这意味着当等待另一个开发人员提交并推送其代码副本时,您可以在同一分支中尝试一些操作。 Git鼓励它。 每当您准备将新的更改拉到本地存储库,但又不想将自己的编辑合并到本地存储库时,则必须保存自己的编辑。 Git藏匿处会将副本保存在其他地方,您可以通过执行Git藏匿处列表进行访问。

The git merge a command that merges two different snapshots together. It can be merging different snapshots of the same branch by different developers or merging different snapshots of different branches together.

git merge一个将两个不同快照合并在一起的命令。 它可以由不同的开发人员合并同一分支的不同快照,也可以将不同分支的不同快照合并在一起。

When you’ve checked out to the master branch, git merge development will merge the development branch to your master branch and vice versa.

当您签出到master分支后,git merge development将把development分支合并到您的master分支,反之亦然。

git推 (Git push)

Just like saving your snapshots to a Google Photos album for whomever you share the album with, think of git push as sending your local repository to the remote repository for others to access.

就像将快照保存到与他人共享相册的Google Photos相册一样,将git push视为将本地存储库发送到远程存储库,以供其他人访问。

git push -u origin branch-name

git push -u origin branch-name

While there are other Git commands available for use, it’s interesting what you can achieve by mastering the few that I’ve covered above.

尽管还有其他可用的Git命令,但有趣的是,您可以掌握上面已经介绍的几个命令来实现。

Feel free to reach out and ask me any questions on Twitter

随时联系并在Twitter上问我任何问题

James Okunlade (@JamesOkunlade) | TwitterThe latest Tweets from James Okunlade (@JamesOkunlade). Full-stack SWE | JavaScript/React/Redux | Ruby/Ruby on Rails |…twitter.com

詹姆斯·奥昆拉德(@JamesOkunlade)| Twitter 来自James Okunlade(@JamesOkunlade)的最新推文。 全栈SWE | JavaScript / React / Redux | Ruby / Ruby on Rails |… twitter.com

def JamesOkunlade (beginnerDeveloper)
unless you have a coding buddy OR you’re making a lot of money
doing it
puts “Coding is not fun!”
end
end

I’m from Nigeria and I pair program every day with my coding buddy from Bangladesh and other devs from Serbia, Kosovo, and Ukraine. They’ve all helped my use of Git.

我来自尼日利亚,每天与孟加拉的编码伙伴以及来自塞尔维亚,科索沃和乌克兰的其他开发人员配对程序。 他们都帮助了我使用Git。

As a student, I do remote pair programming for at least 40 hours every week. Learning programming as a beginner can be very tedious and hence, reduces the productivity and hardens the learning curve. With a right coding partner, however, and under a proper structure, you’d be surprised at how interesting learning could be.

作为一名学生,我每周至少进行40个小时的远程配对编程。 初学者学习编程可能非常繁琐,因此会降低生产率并加深学习难度。 但是,如果选择了合适的编码合作伙伴,并且结构正确,您会惊讶于学习会变得多么有趣。

James Okunlade - Software Developer - Filmdrive | LinkedInView James Okunlade's profile on LinkedIn, the world's largest professional community. James has 2 jobs listed on their…www.linkedin.com

James Okunlade-Filmdrive软件开发人员| LinkedIn 查看詹姆斯Okunlade对LinkedIn,世界上最大的专业的社区形象。 詹姆斯在他们的网站列出了2个工作 。www.linkedin.com

翻译自: https://www.freecodecamp.org/news/the-essentials-of-git-explained-in-five-minutes-d554019eded9/

git 代理 git

git 代理 git_五分钟解释Git的要点相关推荐

  1. git 代理 git_如何不再害怕GIT

    git 代理 git 了解减少不确定性的机制 (Understanding the machinery to whittle away the uncertainty) 到底什么是Git? (What ...

  2. Git进阶(五):git 分支管理策略

    文章目录 一.企业级项目分支策略 1.1 主分支 master 1.2 开发分支 develop 1.3 功能分支 feature 1.4 预发布分支 release 1.5 bug 分支 fixbu ...

  3. git 代理 git_如何成为Git专家

    git 代理 git I made a mistake in my commit, how do I fix it ? 我在提交中犯了一个错误,该如何解决? My commit history is ...

  4. git 代理 git_万物Git的资源

    git 代理 git Following my post on Git and its basic definitions, I decided to bundle up some more arti ...

  5. git 代理 git_生日快乐,Git

    git 代理 git 在版本控制领域,Git显然宣称了大多数开发人员首选的版本控制工具. 在最近一次有关Stack Overflow的开发人员调查中 ,Git是69.2%的参与者的首选版本控制,其票数 ...

  6. 【Git】每天1分钟系列——Git本地与远程服务器介绍

    本地与服务器 本地与服务器交互的方式及命令如下 推送指将特定分支在本地仓库区的记录发送到服务器上 获取指将服务器特定分支向本地工作区同步 获取 建议:在每天开始编写代码前,先与服务器同步一次:或者在公 ...

  7. 2015年01月30日 - Git五分钟教程

    2019独角兽企业重金招聘Python工程师标准>>> 许多人认为Git太混乱或是复杂的版本控制系统,这篇文章是面向一些人想快速上手使用Git, 对于大多数基本需求这篇文章涵盖了使用 ...

  8. git FreshMan指南,五分钟上手(图解)

    目录 一.Git 工作流程 二.Git 工作区.暂存区和版本库 基本概念 三.Git 的基本操作 创建仓库命令 提交与修改 提交日志 远程操作 四.Git 分支管理 五.Git 查看提交历史 一.Gi ...

  9. 十分钟了解 git 那些 “不常用” 命令

    点击上方 好好学java ,选择 星标 公众号 重磅资讯.干货,第一时间送达 今日推荐:Java实现QQ登录和微博登录个人原创+1博客:点击前往,查看更多 链接:https://segmentfaul ...

最新文章

  1. 使用Python,OpenCV,dlib进行睡意检测(疲劳驾驶检测)
  2. react 执行 yarn build 页面无法显示
  3. TSQL--NESTED LOOPS JOIN
  4. 转!!配置Tomcat时server.xml和content.xml自动还原问题
  5. BZOJ 4006 Luogu P3264 [JLOI2015]管道连接 (斯坦纳树、状压DP)
  6. IDEA设置注释颜色
  7. Linux之ubuntu的网卡配置
  8. 好玩的Scratch
  9. 虚拟网关与正规网关的区别
  10. 计算机科学家 收入,你离年薪100万的数据科学家还差10个“码农”
  11. Phoenix+Hbase二级索引
  12. linux文件IO的操作
  13. html中使用js实现体彩大乐透随机选号
  14. 爬虫网页框架代码和媒体对象
  15. oracle快照点,Oracle快照(snapshot)管理
  16. 论文写作 2: 常见的 Latex 格式文件
  17. 酷柚易汛进销存开发进度一览表以及各版本之间区别!
  18. hao643.com劫持(修改快捷方式跳转至hao123.com)
  19. MySQL(图形化界面)
  20. 设置custom debug keystore

热门文章

  1. leetcode算法—两数之和 Two Sum
  2. ArrayList 有序集合 c#
  3. 前端错误日志上报相关实践
  4. eclipse黑色主题
  5. apache开源项目 -- tajo
  6. 回顾一下Unix哲学
  7. 用最科学的方法展示最形象的图表——前段数据可视化选型实践
  8. Mac下搭建Cocos2d-x-3.2的开发环境详解
  9. SCCM 2007 R2 报表问题(二)
  10. 入门代码教程第六节 如何:使用客户端