Git:添加vs推送vs提交 [英] Git: add vs push vs commit

查看:150
本文介绍了Git:添加vs推送vs提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git add push commit

只是有点困惑来自SVN,其中更新将添加的东西,提交做一个推,并将添加作为好的

git中有所有不同的功能。希望从您的经验中得到一些解释。 code>将修改后的文件添加到队列以稍后提交。文件未提交

  • git commit 提交已添加的文件并创建一个带有日志的新版本。 。如果你不添加任何文件,git不会提交任何东西。您可以将这两个操作与 git commit -a


  • git push 将更改推送到远程存储库。

  • 这个git备忘单给出了一个好主意流量





    git add 不在图中,因为建议的提交方式是合并的 git commit - 一个,但是您可以在变化区块上弱智地添加 git add 以了解流程。


    $ b $最后, push 是一个单独的命令的原因是因为 git 的哲学。 git 是一个分布式版本控制系统,您的本地工作目录您的资源库!您提交的所有更改都会立即反映和记录。 push 仅用于在您完成正在处理的任何事情时更新远程回购(您可能会与其他人共享)。这是一种简洁的工作方式,可以在本地保存更改(无需网络开销),只在需要时更新,而不是在每次提交时更新。这间接地导致了更容易的提交/分支等(为什么不,对吗?它会花费你什么?),这导致更多的存储点,而不会干扰存储库。


    What is the difference between git add, push and commit?

    Just a little confused coming from SVN, where "update" will 'add' stuff, and commit does a "push" and will 'add' as well

    There are all different functions within git. Hoping for some explanation from your experience.

    解决方案

    1. git add adds your modified files to the queue to be committed later. Files are not committed
    2. git commit commits the files that have been added and creates a new revision with a log... If you do not add any files, git will not commit anything. You can combine both actions with git commit -a

    3. git push pushes your changes to the remote repository.

    This figure from this git cheat sheet gives a good idea of the work flow

    git add isn't on the figure because the suggested way to commit is the combined git commit -a, but you can mentally add a git add to the change block to understand the flow.

    Lastly, the reason why push is a separate command is because of git's philosophy. git is a distributed versioning system, and your local working directory is your repository! All changes you commit are instantly reflected and recorded. push is only used to update the remote repo (which you might share with others) when you're done with whatever it is that you're working on. This is a neat way to work and save changes locally (without network overhead) and update it only when you want to, instead of at every commit. This indirectly results in easier commits/branching etc (why not, right? what does it cost you?) which leads to more save points, without messing with the repository.

    这篇关于Git:添加vs推送vs提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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