0

我在服务器中有一个 git 存储库,我必须将数据推送和拉入其中。当我试图拉取一个实例时,我的很多文件都被删除了,即使它存在于存储库中。我使用的命令如下

git add .
git add -u
git commit -m 'comments'
git pull origin master

这是在终端运行这些命令时发生的情况

manesh@sysadmin-PC:/var/www/MobpazAdmin$ git add .
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git add -u
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git commit -m 'with add ads'
[master 5706969] with add ads
Committer: Manesh <manesh@sysadmin-PC.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

10 files changed, 523 insertions(+), 5 deletions(-)
create mode 100755 src/Mobpaz/AdminBundle/Controller/AdsController.php
create mode 100644 src/Mobpaz/AdminBundle/Entity/Ads.php
create mode 100644 src/Mobpaz/AdminBundle/Entity/AdsRepository.php
create mode 100644          src/Mobpaz/AdminBundle/Resources/config/doctrine/metadata/orm/Ads.orm.xml
create mode 100755 src/Mobpaz/AdminBundle/Resources/views/Ads/addads.html.twig
create mode 100755 src/Mobpaz/AdminBundle/Resources/views/Ads/index.html.twig
mode change 100644 => 100755 src/Mobpaz/AdminBundle/Resources/views/Logs/index.html.twig
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git pull origin master
git@192.168.10.241's password: 
remote: Counting objects: 50, done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 28 (delta 14), reused 0 (delta 0)
Unpacking objects: 100% (28/28), done.
From 192.168.10.241:/var/www/repositories/Mobpaz/MobpazAdmin
* branch            master     -> FETCH_HEAD  
Auto-merging src/Mobpaz/AdminBundle/Resources/views/base.html.twig
Auto-merging src/Mobpaz/AdminBundle/Resources/views/Logs/index.html.twig
Auto-merging src/Mobpaz/AdminBundle/Resources/config/routing.yml
CONFLICT (content): Merge conflict in   src/Mobpaz/AdminBundle/Resources/config/routing.yml
Automatic merge failed; fix conflicts and then commit the result.
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git add .
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git add -u
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git commit -m 'with add ads'
[master 0c0e548] with add ads
Committer: Manesh <manesh@sysadmin-PC.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

manesh@sysadmin-PC:/var/www/MobpazAdmin$ git commit -m 'with add ads'
# On branch master
nothing to commit (working directory clean)
manesh@sysadmin-PC:/var/www/MobpazAdmin$ git pull origin master
git@192.168.10.241's password: 
From 192.168.10.241:/var/www/repositories/Mobpaz/MobpazAdmin
* branch            master     -> FETCH_HEAD
Already up-to-date.

在进行第二次拉动之前,我解决了第一次拉动中发生的冲突。请告诉我我做错了什么这种情况经常发生,因此我的工作在每次推拉后都会被打断。

我的问题是,即使存储库中的文件也会从我的本地副本中删除。

4

1 回答 1

2

我认为您误解了commit与 相比的内容push

commit创建一个本地暂存区供您使用。这完全是本地的,您的 git 服务器不知道这些更改。

push您进行更改时(在committing 之后),您的服务器将保存您的更改。

抱歉,如果我在这里不正确,您的日志只是没有任何push电话。

于 2013-11-01T04:59:13.083 回答