如何将某些文件推送到Git中的原始服务器/主服务器?
我对Git有点陌生.我想将一些文件推送到我的Git来源(远程).
I am little bit new to Git. I would like to push some files to my Git origin (remote).
我做了什么:
我有我的主人,我创建了一个分支来做一些工作.之后,我将分支合并到了我的主人.在我的工作期间,许多二进制文件和项目文件在本地进行了更改/添加.我希望仅 添加已更改为远程服务器的 .java 文件.
I had my master, and 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.
(我相信我在自己的分支机构工作时曾尝试过 commits ,只是为了检查其工作原理.)
(I believe that I experimented with commits when I worked on my branch, just to check how it work.)
我的主人对我的起源是最新的(这是我做git pull
时得到的.我也做了git fetch origin
.
我总是收到(当我运行git status
时):
My master is up to date with my origin (that is what I get when I do git pull
. Also I did git fetch origin
.
I always received (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`
我试图添加,提交这些文件,但是运行git status
并没有改变.我尝试在新分支上进行添加,提交:
I tried to add, commit those files, but running git status
wasn't changed. I tried to do add, commit on the new branch:
On branch NewBranch nothing to commit, working directory clean
我试图重置Head.在Git教程或Stack Overflow中找不到我的问题的解决方案.
I tried to reset Head. I didn't find a solution for my problem in the Git tutorial or on Stack Overflow.
我当然可以将所有文件推送到远程源,但是我认为这不是一个好的解决方案.
Of course I can push all files to remote origin, but I don't think it's a good solution.
我发现了一些重复的问题: 如何推送单个文件,如何将更改仅推送到和如何仅提交某些文件?
Some duplicate questions that I found: How to push a single file, how to push changes made to only certain files?, and How to commit only some files?.
我解决了我的问题:(我对git status响应感到困惑,因为当我尝试添加/提交已经存在的文件时,它没有被更改).感谢linuxdan和DaveZych和Temich.
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
移回母版
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