[英]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 init
和git 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 fetch
和git 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.