I recently delete all file from current branch, with rm --cached
command without delete .git
folder. Then staged just one file in current branch. But when I try to push that file to remote repository, there seems other file also partake to transfer.
I need to ask two question: 1. Is deleting file from current branch also delete that file from repository? 2. How just to transfer (push
) file in current branch, not all file in repo.
Asked
Active
Viewed 87 times
1

Mohammad Fajar
- 957
- 1
- 12
- 24
-
1. No 2. You don't push "files" but "changesets" – zerkms Feb 25 '14 at 02:37
-
How to accomplish that? – Mohammad Fajar Feb 25 '14 at 02:58
-
to accomplish *what*? – zerkms Feb 25 '14 at 02:59
-
Sorry, I dont fully understand, what you mean with changesets? – Mohammad Fajar Feb 25 '14 at 03:00
-
So I need to commit before to push that file? – Mohammad Fajar Feb 25 '14 at 03:05
-
you **cannot** push a file, you only push commits – zerkms Feb 25 '14 at 03:10
-
Thats what i mean... is possible to push only the last commit. I mean in the last commit I deleta all file except one... so I need to push only commit about that file thereafter. – Mohammad Fajar Feb 25 '14 at 03:18
-
1Don't you need the other commits at all? – zerkms Feb 25 '14 at 03:19
1 Answers
0
1/ Is deleting file from current branch also delete that file from repository?
No.
2/ How just to transfer (push) file in current branch, not all file in repo.
you will push all un-pushed commits, not just the last one
You can push only the current branch, with the default push policy "simple".
Your first push should be
git push -u origin yourBranch
But that branch will include all the commits, including your last one (which reference only one file).
If you really want to reset the content of the remote upstream repo, you can have a look at "How to reset a remote GIT repository to remove all commits?".