how to stop pushing deleted files to remote repo?
I committed some files and tried to push them to the remote repository.
However, I found a large video file in the list and terminated the pushing.
And then I tried to delete the file from the list and pushed again.
$git commit -m "comments" -a
$git push origin my_branch
... # I found mp4 file here and terminated push
$git rm --cached path/to/mp4
$git commit -m "comments" -a
$git push origin my_branch
Problem
git still tried to push the mp4 file to repo.
Question
How do I avoid the deleted file pushing to remote repo?
PS
I also tried git rm path/to/mp4
, the file has removed from my directory but git still tried to push the file to repo
git github
add a comment |
I committed some files and tried to push them to the remote repository.
However, I found a large video file in the list and terminated the pushing.
And then I tried to delete the file from the list and pushed again.
$git commit -m "comments" -a
$git push origin my_branch
... # I found mp4 file here and terminated push
$git rm --cached path/to/mp4
$git commit -m "comments" -a
$git push origin my_branch
Problem
git still tried to push the mp4 file to repo.
Question
How do I avoid the deleted file pushing to remote repo?
PS
I also tried git rm path/to/mp4
, the file has removed from my directory but git still tried to push the file to repo
git github
Do a git checkout remove the file using git rm and again push the file. This will delete the file for sure.
– Arihant Godha
May 19 '14 at 5:53
add a comment |
I committed some files and tried to push them to the remote repository.
However, I found a large video file in the list and terminated the pushing.
And then I tried to delete the file from the list and pushed again.
$git commit -m "comments" -a
$git push origin my_branch
... # I found mp4 file here and terminated push
$git rm --cached path/to/mp4
$git commit -m "comments" -a
$git push origin my_branch
Problem
git still tried to push the mp4 file to repo.
Question
How do I avoid the deleted file pushing to remote repo?
PS
I also tried git rm path/to/mp4
, the file has removed from my directory but git still tried to push the file to repo
git github
I committed some files and tried to push them to the remote repository.
However, I found a large video file in the list and terminated the pushing.
And then I tried to delete the file from the list and pushed again.
$git commit -m "comments" -a
$git push origin my_branch
... # I found mp4 file here and terminated push
$git rm --cached path/to/mp4
$git commit -m "comments" -a
$git push origin my_branch
Problem
git still tried to push the mp4 file to repo.
Question
How do I avoid the deleted file pushing to remote repo?
PS
I also tried git rm path/to/mp4
, the file has removed from my directory but git still tried to push the file to repo
git github
git github
edited Nov 15 '18 at 19:22
Francisco Maria Calisto
4801523
4801523
asked May 19 '14 at 5:07
user001user001
132128
132128
Do a git checkout remove the file using git rm and again push the file. This will delete the file for sure.
– Arihant Godha
May 19 '14 at 5:53
add a comment |
Do a git checkout remove the file using git rm and again push the file. This will delete the file for sure.
– Arihant Godha
May 19 '14 at 5:53
Do a git checkout remove the file using git rm and again push the file. This will delete the file for sure.
– Arihant Godha
May 19 '14 at 5:53
Do a git checkout remove the file using git rm and again push the file. This will delete the file for sure.
– Arihant Godha
May 19 '14 at 5:53
add a comment |
2 Answers
2
active
oldest
votes
From those commands it looks like the video file is still in the commit history.
Assuming you have made no other commits try the following. If you have just tweak them a bit.
Try reverting to the previous commit
git reset --soft HEAD~1
then do git status and see if you see the file
if you do. then remove it and recommit with
git commit -c ORIG_HEAD
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
add a comment |
If the history is larger than just one commit, and the mp4 large file has been versioned in older commits, you can consider cleaning up the history of your repo with:
git filter-branch
(as in this answer),or with BFG.
bfg --strip-blobs-bigger-than 1M my-repo.git
Follow that cleanup with a git gc --aggressive --prune=now
(as explained here)
To "roll back", simply try those operations on a local clone of your current local repo (so a second local repo, clone of the first). If the end result isn't good, you can resume in the first (untouched) repo.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23730052%2fhow-to-stop-pushing-deleted-files-to-remote-repo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
From those commands it looks like the video file is still in the commit history.
Assuming you have made no other commits try the following. If you have just tweak them a bit.
Try reverting to the previous commit
git reset --soft HEAD~1
then do git status and see if you see the file
if you do. then remove it and recommit with
git commit -c ORIG_HEAD
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
add a comment |
From those commands it looks like the video file is still in the commit history.
Assuming you have made no other commits try the following. If you have just tweak them a bit.
Try reverting to the previous commit
git reset --soft HEAD~1
then do git status and see if you see the file
if you do. then remove it and recommit with
git commit -c ORIG_HEAD
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
add a comment |
From those commands it looks like the video file is still in the commit history.
Assuming you have made no other commits try the following. If you have just tweak them a bit.
Try reverting to the previous commit
git reset --soft HEAD~1
then do git status and see if you see the file
if you do. then remove it and recommit with
git commit -c ORIG_HEAD
From those commands it looks like the video file is still in the commit history.
Assuming you have made no other commits try the following. If you have just tweak them a bit.
Try reverting to the previous commit
git reset --soft HEAD~1
then do git status and see if you see the file
if you do. then remove it and recommit with
git commit -c ORIG_HEAD
answered May 19 '14 at 5:13
BachmannBachmann
533310
533310
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
add a comment |
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
thanks, before I try the solution, may I know the solution will roll back my changes?
– user001
May 19 '14 at 5:23
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
Reset --soft should not roll anything back until you commit. It returns you to the state before the commit. All The changes in that commit will show up in the staging area.
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
If you're unsure just init a git repo in another folder and experiment. Or make a new branch and try the command there. Even if something does go wrong, the reflog is your friend
– Bachmann
May 19 '14 at 6:04
add a comment |
If the history is larger than just one commit, and the mp4 large file has been versioned in older commits, you can consider cleaning up the history of your repo with:
git filter-branch
(as in this answer),or with BFG.
bfg --strip-blobs-bigger-than 1M my-repo.git
Follow that cleanup with a git gc --aggressive --prune=now
(as explained here)
To "roll back", simply try those operations on a local clone of your current local repo (so a second local repo, clone of the first). If the end result isn't good, you can resume in the first (untouched) repo.
add a comment |
If the history is larger than just one commit, and the mp4 large file has been versioned in older commits, you can consider cleaning up the history of your repo with:
git filter-branch
(as in this answer),or with BFG.
bfg --strip-blobs-bigger-than 1M my-repo.git
Follow that cleanup with a git gc --aggressive --prune=now
(as explained here)
To "roll back", simply try those operations on a local clone of your current local repo (so a second local repo, clone of the first). If the end result isn't good, you can resume in the first (untouched) repo.
add a comment |
If the history is larger than just one commit, and the mp4 large file has been versioned in older commits, you can consider cleaning up the history of your repo with:
git filter-branch
(as in this answer),or with BFG.
bfg --strip-blobs-bigger-than 1M my-repo.git
Follow that cleanup with a git gc --aggressive --prune=now
(as explained here)
To "roll back", simply try those operations on a local clone of your current local repo (so a second local repo, clone of the first). If the end result isn't good, you can resume in the first (untouched) repo.
If the history is larger than just one commit, and the mp4 large file has been versioned in older commits, you can consider cleaning up the history of your repo with:
git filter-branch
(as in this answer),or with BFG.
bfg --strip-blobs-bigger-than 1M my-repo.git
Follow that cleanup with a git gc --aggressive --prune=now
(as explained here)
To "roll back", simply try those operations on a local clone of your current local repo (so a second local repo, clone of the first). If the end result isn't good, you can resume in the first (untouched) repo.
edited May 23 '17 at 11:50
Community♦
11
11
answered May 19 '14 at 5:38
VonCVonC
846k29426823237
846k29426823237
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23730052%2fhow-to-stop-pushing-deleted-files-to-remote-repo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do a git checkout remove the file using git rm and again push the file. This will delete the file for sure.
– Arihant Godha
May 19 '14 at 5:53