了解 Git 和 GitHub 的基础知识 [英] Understanding the basics of Git and GitHub

查看:27
本文介绍了了解 Git 和 GitHub 的基础知识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不完全理解使用 Git 或 Github 的目的;我知道跟踪您的更改会有所帮助,对于与其他人合作的人也很有帮助,但我不与任何人合作,所以我不知道这对我是否有帮助.

我通常担任网页设计师/开发人员,但我从不需要合作.我知道在 Git 中,您为每个存储库创建、推送、提交、创建分支等,但是...

  1. Git 和 GitHub 有什么区别?

  2. git 是否在本地(在用户的机器中)和在 GitHub 中保存每个存储库?

  3. 你可以在没有 GitHub 的情况下使用 Git 吗?如果是,使用 GitHub 有什么好处?

  4. Git 与 Time Machine 等备份系统相比如何?

  5. 这是一个手动过程吗,换句话说,如果您不提交,您将不会有所做更改的新版本?

  6. 如果不合作并且您已经在使用备份系统,为什么还要使用 Git?

解决方案

  1. Git 和 GitHub 有什么区别?

    Git 是一个版本控制系统;将其视为代码的一系列快照(提交).您会看到这些快照的路径,按照它们创建的顺序.您可以创建分支进行实验并返回您拍摄的快照.

    GitHub 是一个网页,您可以在该网页上发布您的 Git 存储库并与其他人协作.

  2. Git 是否在本地(在用户的机器中)和 GitHub 中保存每个存储库?

    不,它只是本地的.您可以决定在 GitHub 上推送(发布)一些分支.

  3. 没有 GitHub 可以使用 Git 吗?如果是,使用 GitHub 有什么好处?

    是的,如果您不使用 GitHub,Git 会在本地运行.使用 GitHub 的另一种方法是在 Dropbox 上托管的文件上运行 Git,但 GitHub 是一种更加简化的服务,因为它是专为 Git 设计的.

  4. Git 与 Time Machine 等备份系统相比如何?

    这是另一回事,Git 可让您跟踪更改和开发过程.如果您将 Git 与 GitHub 一起使用,它就变成了有效的备份.然而,通常你不会一直推送到 GitHub,此时如果出现问题,你没有完整的备份.我在与 Dropbox 同步的文件夹中使用 git.

  5. 这是一个手动过程吗,换句话说,如果您不提交,您将不会有所做更改的新版本?

    是的,提交和推送都是手动的.

  6. 如果不合作并且您已经在使用备份系统,为什么还要使用 Git?

    • 如果您在两次提交之间遇到错误,您可以使用命令 git diff 查看当前代码与上次提交之间的差异,帮助您定位错误.p>

    • 你也可以回到上次工作提交.

    • 如果您想尝试更改,但不确定它是否会起作用.您创建一个分支来测试您的代码更改.如果它工作正常,你将它合并到主分支.如果没有,您只需将分支扔掉并返回主分支.

    • 你做了一些调试.在提交之前,您总是会查看上次提交的更改.您会看到忘记删除的调试打印语句.

请务必查看 gitimmersion.com.

I don't fully understand the purpose of using Git or Github; I know it helps to keep track of your changes and it's helpful for people collaborating with other people, but I don't collaborate with anybody so I don't know if this would be helpful for me.

I usually work as a web designer/developer but I never have to collaborate. I know in Git you have create, push, commit, create branches etc for every repository but...

  1. What is the difference between Git and GitHub?

  2. Is git saving every repository locally (in the user's machine) and in GitHub?

  3. Can you use Git without GitHub? If yes, what would be the benefit for using GitHub?

  4. How does Git compare to a backup system such as Time Machine?

  5. Is this a manual process, in other words if you don't commit you wont have a new version of the changes made?

  6. If are not collaborating and you are already using a backup system why would you use Git?

解决方案

  1. What is the difference between Git and GitHub?

    Git is a version control system; think of it as a series of snapshots (commits) of your code. You see a path of these snapshots, in which order they where created. You can make branches to experiment and come back to snapshots you took.

    GitHub, is a web-page on which you can publish your Git repositories and collaborate with other people.

  2. Is Git saving every repository locally (in the user's machine) and in GitHub?

    No, it's only local. You can decide to push (publish) some branches on GitHub.

  3. Can you use Git without GitHub? If yes, what would be the benefit for using GitHub?

    Yes, Git runs local if you don't use GitHub. An alternative to using GitHub could be running Git on files hosted on Dropbox, but GitHub is a more streamlined service as it was made especially for Git.

  4. How does Git compare to a backup system such as Time Machine?

    It's a different thing, Git lets you track changes and your development process. If you use Git with GitHub, it becomes effectively a backup. However usually you would not push all the time to GitHub, at which point you do not have a full backup if things go wrong. I use git in a folder that is synchronized with Dropbox.

  5. Is this a manual process, in other words if you don't commit you won't have a new version of the changes made?

    Yes, committing and pushing are both manual.

  6. If are not collaborating and you are already using a backup system why would you use Git?

    • If you encounter an error between commits you can use the command git diff to see the differences between the current code and the last working commit, helping you to locate your error.

    • You can also just go back to the last working commit.

    • If you want to try a change, but are not sure that it will work. You create a branch to test you code change. If it works fine, you merge it to the main branch. If it does not you just throw the branch away and go back to the main branch.

    • You did some debugging. Before you commit you always look at the changes from the last commit. You see your debug print statement that you forgot to delete.

Make sure you check gitimmersion.com.

这篇关于了解 Git 和 GitHub 的基础知识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆