doulang1945 2014-05-02 08:48
浏览 20
已采纳

对GIT存储库的概念感到困惑[关闭]

I went for an interview where they asked me whether I use GIT-REPOSITORIES to merge my projects. For which I was quite. I looked Wikipedia and Other stuff on net for this but didn't find anything that can force me to go for it. Please tell me what exactly is GIT-REPOSITORIES and how is it useful. Is it beneficial for me as I am totally confused by all that stuff on the internet ?

Currently, I create projects in PHP by dividing them into smaller independent modules and then merge them all by myself.

  • 写回答

2条回答 默认 最新

  • dongxiangchan0743 2014-05-02 08:58
    关注

    Git is just one of several types of source control software.

    At my day job, we use Mercurial, which is a DVCS (Distributed version control system).

    Imagine you're working on a website and you've got a remote server. I guess right now you're downloading files via FTP, editing them, and uploading them. Do you take backups incase it goes wrong? What if you mix up backups, or you're not sure which change made the error? Then I guess you've got to manually re-upload each of these files into the right places, which will likely break the website for a period of time as files are out of sync.

    Also imagine you're working on a codebase that's also being worked on by colleagues. Dave tells you he's just finished all that work on db-abstract.php, but then you get a sinking feeling, as you've just changed a load of code in db-abstract.php too.

    With source control, when you make changes to files, you commit the changes, and the changes you've made are all recorded. It's recorded what lines of code you've added, and what you've removed.

    When you've finished your work you can "push" them to a central repository where others can "pull" your changes. If you and Dave realise you've worked on the same file, you'll get a merge conflict. You'll then be shown a two sided screen where the changes Dave made, and the changes you made are compared. It'll try to merge them automatically, but if it can't, it'll ask for your help. You can then clearly see which bits of code have been added, changed and why. You'll merge the files together, then commit that change.

    Eventually you end up with a whole load of changes that add a brand new feature to a system across possibly hundreds of files, these will all be grouped together into a branch, which describes the feature. All you have to do to make those changes live is push them to the live server, and on the live server, update it's working directory to this branch, or merge the branch into it's default branch. All the changes will instantly be live. If anything went wrong on the live server, or from user testing, you can simply "rollback" which will instantly revert all those changed files to their previous versions.

    Once you've worked with source control you'll never go back and you simply cannot work on large code bases collaboratively with other devs without it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名