简体   繁体   English

如何使用git? git-commit? git-push?

[英]How to use git ? git-commit ? git-push?

I am working on a website, and I need to use Git for practical reasons. 我正在一个网站上工作,出于实际原因,我需要使用Git。 However, I think I have not totally understood how it works. 但是,我想我还没有完全理解它是如何工作的。

I want to do something quite simple, and I am working on localhost. 我想做一些非常简单的事情,并且我正在localhost上工作。 I make several changes, and sometimes I use Git for put the new or modify files on the server. 我进行了一些更改,有时我使用Git在服务器上放置新文件或修改文件。

Edit²: after reading some docs, I have reinit all my git repositories. 编辑²:阅读一些文档后,我重新初始化了所有的git存储库。 I really understand nothing to git. 我真的不懂git。 So, I connect to my server, and I commit the files. 因此,我连接到服务器,并提交了文件。 After I reinit my local repository. 重新初始化本地存储库之后。 I add my remote and I did git pull carpe master (carpe is my alias for the remote server). 我添加了我的遥控器,然后我做了git pull carpe master (carpe是我的远程服务器别名)。 If I do git checkout master on local, I see all the paths from the tracked files from the server. 如果我在本地执行git checkout master,我会从服务器中看到跟踪文件的所有路径。 But git did not download the files to the working tree... I really do not understand. 但是git没有将文件下载到工作树中……我真的不明白。 What should I do for getting the file in my local working tree ? 如何在本地工作树中获取文件?

By pushing, you've sent your commits to the remote git repository at ssh://user@myname.my/mypath/.git . 通过推送,您已将提交发送到ssh://user@myname.my/mypath/.git的远程git存储库。 However, the content of this repository is independent to what your Web server is serving -- the HTML you see in your browser (this is known as the working copy ). 但是,该存储库的内容与Web服务器所服务的内容无关,即您在浏览器中看到的HTML(称为工作副本 )。 What you need to do now is to pull the changes from the repository into the server's working copy ( git pull origin ). 您现在需要做的是将更改从存储库中拉入服务器的工作副本( git pull origin )。

It's really worth putting in the time to go through a decent git tutorial, as others have suggested. 正如其他人所建议的那样,真的值得花一些时间来完成一个不错的git教程。 My personal favorite is http://gitimmersion.com/ . 我个人最喜欢的是http://gitimmersion.com/

You have just pushed your changes from the local master branch to the remote master branch. 您刚刚将更改从本地master分支推送到了远程master分支。 (ie sent your changes to the remote server.) (即,将您的更改发送到远程服务器。)

Have a look here for a descent introduction to git 在这里看看git的血统介绍

This may help: https://stackoverflow.com/a/9204499/631619 这可能会有所帮助: https : //stackoverflow.com/a/9204499/631619

I think the key things to know are: 我认为关键要知道的是:

tracking branches & 'origin'. 跟踪分支和“来源”。 Understanding this is key. 了解这一点很关键。 It's the inbetween part of how changes flow to and from remote servers and local environments. 这是更改如何往返于远程服务器和本地环境的中间部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM