简体   繁体   English

如何将GIT更改从一个克隆推送到另一个克隆?

[英]How do I push GIT changes from one clone to another?

I'm just getting started with git. 我刚刚开始使用git。 I've spent the past 8 hours reading every guide and tutorial online. 在过去的8个小时中,我已经在线阅读了所有指南和教程。 I'm still somewhat of a newbie to git, so please forgive if this question is dumb, or maybe I'm even asking the wrong question. 我仍然是git的新手,所以如果这个问题很愚蠢,请原谅,或者我什至在问错一个问题。 Just know I've spent a fair amount of time researching this before I asked here. 只是知道我在这里问过之前已经花了很多时间进行研究。

I have two environments: TEST & DEV. 我有两个环境:TEST&DEV。 So far we've literally just been copying and pasting the updated files via FTP. 到目前为止,我们实际上只是通过FTP复制和粘贴更新的文件。 I know this is bad. 我知道这很糟糕。 So today I wanted to get this under git control. 所以今天我想让它在git控制下。

So... I backed up all my files. 所以...我备份了所有文件。 SSHed into TEST and performed git init , git add . SSH进入TEST并执行git initgit add . , git commit -m "First Commit" , and finally git push . git commit -m "First Commit" ,最后git push Then I opened up a new Terminal window and SSHed into DEV. 然后,我打开了一个新的“终端”窗口,并通过SSH登录到DEV。 In dev I created a new empty folder and performed git clone username@TEST:/path . 在开发人员中,我创建了一个新的空文件夹并执行git clone username@TEST:/path

Everything seemed fine. 一切似乎都很好。

Then I added some new files to DEV and tried to push the changes up to TEST and it's just not working. 然后,我向DEV添加了一些新文件,并尝试将所做的更改推送到TEST,但它不起作用。 When I go into TEST and type git status it shows my commits, but the new files aren't there. 当我进入TEST并输入git status它显示了我的提交,但是新文件不存在。

Question: How do I push files up from my DEV clone to TEST? 问题:如何将文件从DEV克隆上移到TEST?

Note: I don't have any branches or anything really complicated. 注意:我没有任何分支机构或任何真正复杂的机构。 This is a basic set up. 这是基本设置。 Am I doing this wrong/dumb? 我做错了吗?

git status doesn't show commits - it shows the status of the working copy . git status不显示提交-它显示工作副本的状态。

On DEV , you should git add each file, then git commit , then finally git push . DEV ,您应该git add每个文件,然后git commit ,最后是git push This will put your changes into the repository ( .git directory) on TEST . 这会将您的更改放入TEST存储库.git目录)中。

If you've already done that, you need to do a git merge (or git pull , which is the equivalent of git fetch and git merge ) on test to get the latest changes into the working copy there - the changesets are in the branch, but your checkout is out of date. 如果已经这样做,则需要在测试中进行git merge (或git pull ,等效于git fetchgit merge ),以将最新的更改获取到工作副本中-更改集在分支中,但您的结帐日期已过时。

Ok, so if you want to push stuff from a repository (TEST) to another repository (DEV), you have to create a new REMOTE. 好的,因此,如果要将内容从存储库(TEST)推送到另一个存储库(DEV),则必须创建一个新的REMOTE。

When you do PUSH or PULL, you're transfering content between your repository and one of his REMOTE. 当您执行PUSH或PULL时,您正在存储库和他的REMOTE之一之间传输内容。 The default remote is known as ORIGIN, but you can create new remote as much as needed. 默认远程称为ORIGIN,但是您可以根据需要创建新的远程。

git remote add REMOTE_NAME REMOTE_URL_OR_PATH

You can list remote with: 您可以使用以下方式列出远程:

git remote -v

And you can push to a specific remote like so: 您可以像这样推送到特定的遥控器:

git push REMOTE_NAME BRANCH_NAME

or pull: 或拉:

git pull REMOTE_NAME BRANCH_NAME

Some extra documentation: http://help.github.com/remotes/ 一些额外的文档: http : //help.github.com/remotes/

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

相关问题 如何将更改推送到该GIT克隆中未进行的分支中? - How do I push changes into a branch that were not made in that GIT clone? 在Git中,如何从一个修订版到另一个修订版获得文件更改的详细列表? - In Git, how do I get a detailed list of file changes from one revision to another? GIT:如何从一个分支还原一个分支的所有更改 - GIT: How Do I Revert All The Changes Of One Branch From Another Branch 我如何将一组更改从一个git repro移至另一个git repro不是克隆 - How do I move a set of changes from one git repro to another — the repros aren't clones 如何使用git从一个遥控器拉入另一个遥控器? - How can I pull from one remote and push to another with git? 我可以在Git中将一个存储库的更改推送到另一个存储库吗? - Can I push changes of one repository to another in Git? 如何将git clone转换为fork然后从fork推送到heroku? - How do I turn a git clone into a fork and then push to heroku from the fork? 如何将更改从一个分支推送到另一个分支? - How to push changes from one branch to another? 如何将 Git 回购从一个帐户克隆到另一个帐户 - How to Clone Git Repo from one account to another 如何在Linux中将git存储库从一台计算机克隆到另一台计算机? - How to clone git repository from one machine to another in linux?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM