如何在git中将某些文件推送到origin / master? [英] How to push certain files to origin/master in git?

查看:560
本文介绍了如何在git中将某些文件推送到origin / master?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我做了什么:
I我有一点新的Git.I想推送一些文件到我的git origin(远程)。有我的主人 - >我创建了一个分支来做一些工作 - >之后,我将我的分支合并到我的主人。在我的工作中,很多二进制文件和项目文件被本地更改/添加。我只想 添加更改为远程服务器的 .java 文件。
(我相信当我在我的分支上工作时,我尝试了 commit 来检查它是如何工作的)



我的主人是我最初的 (当我执行 git pull 时得到的结果也是 git fetch origin
我总是收到:(当我运行 git status 时)

<$ p $ b $ 在分支master上你的分支在12个提交之前在origin / master之前
(使用git push发布你的本地提交)

没有提交,工作目录干净`

我试图添加,提交这些文件但是运行 git status 没有改变
我试图在新分支上添加,提交


 关于分支NewBranch没有提交,工作目录干净

我试图重置Head。
我在git教程或Stack中找不到解决方案。



当然我可以推送所有文件o远程起源,但我不认为它是一个很好的解决方案。
一些重复的问题,我发现:
如何推送单个文件如何将更改仅发送到某些文件?
如何仅提交一些文件?



非常感谢。

我解决了我的问题:(我混淆了git状态响应,因为当我尝试添加/提交已存在的文件时没有更改)。感谢linuxdan和DaveZych和/或Temich。

  git checkout -b NewBranch 

之后,我删除了所有不必要的文件。

  git rm --cache build / web / WEB-INF / classes / doggizz / utils / \ * .class 

移回到master

  git checkout master 

(只有当我移回到主文件时这些文件被删除,所以我手动复制项目文件,我试图隐藏之前结帐但它没有帮助)

  git merge NewBranch 
git push


I am little bit new to Git.I would like to push some files to my git origin(remote).

What I did: I had my master -> I created a branch to do some job -> after that I merged my branch to my master.During my work a lot of binary files and project files were changed/added locally. I would like only to add .java files which changed to remote server. (I believe that I experimented with commits when i worked on my branch. just to check how it work)

My master is is up to date with my origin(that what get when I do git pull also I did git fetch origin. I always receive:(when I ran git status)

On branch master Your branch is ahead of origin/master by 12 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean` 

I tried to add, commit those files but running git status wasn't changed. I tried to to do add, commit on New branch

On branch NewBranch nothing to commit, working directory clean

I tried to reset Head. I didn't find solution for my problem in git tutorial or in Stack.

Of course I can push all files to remote origin but I don't think its a good solution. some duplicate question that I found: How to push a single file,how to push changes made to only certain files?, How to commit only some files?

Thanks A Lot.

解决方案

I solved my problem: (I was confused with git status response because it wasn't changed when I tried to add/commit files which were already there).Thanks to linuxdan and DaveZych and Temich.

git checkout -b NewBranch

After that I deleted all unnecessary files.

git rm --cache build/web/WEB-INF/classes/doggizz/utils/\*.class

Move back to master

git checkout master

(only disadvantage that those files were deleted when I moved back to master so I copied manually project file , I tried to stash before checkout but it didn't helped)

git merge NewBranch
git push

这篇关于如何在git中将某些文件推送到origin / master?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆