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, 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.
(I believe that I experimented with commits when I worked on my branch, just to check how it work.)
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`
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
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?.
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 checkout master
git checkout -b new_branch
git checkout old_branch path/to/some/file
git commit -a
git push origin new_branch:master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With