Reputation: 51
I created a repo on github with some photos included in the original repo, I have redesigned my project and removed the unwanted photos locally, then pushed my changes up to github. The old photos still remain in the github repo...How do I remove them? Did I miss a step somewhere? Im a total newbie and this is very challenging for me. Thank You!
Upvotes: 0
Views: 131
Reputation: 3581
Alright, first off, it looks like your problem stems from the discrepancy from the local repository and the remote repository. The local is the stuff on your computer, which you're editing - but the remote is the one on GitHub's servers. If you change things on local, it does not change things in remote unless you run a few other commands. If you're using Git command-line, there are three things you should learn for this.
A: git push
git push
is Git's command to send files to the remote server. Maneuver to the proper repository with cd
, pick your branch with git checkout <name>
, and then call git push
, which will send those changes up to the website and make them keep.
B: git pull
git pull
is the natural opposite of push
: if the latter sends things up to the server, pull
brings them down, and applies the remote changes to the local repository. Just like push
, maneuver to the repository and branch, and git pull
. (Side note: git fetch
is a similar command, except that it does not overwrite local changes, instead hiding the changes in the secret .git
folder, to be merged later -- in fact, pull
uses fetch
and merge
as a two-step process in one command. But don't worry too much about that.)
C: (Optional) git sync
As mentioned above, pull
is actually just a shortcut for git fetch
and then git merge FETCH_HEAD
. And, in a similar manner, git sync
is a handy command which is aliased to !git pull && git push
-- in other words, it both pulls and pushes changes, all at once. I personally prefer to sync, always, over anything else, though there may be times when you'll prefer to use just one or the other.
That should be the simplest fix to your problem, but if that doesn't cure it, look at the other answers. Maybe the problem isn't as complex as I imagined. In any case, once you can, get a moment to glance at the GitHub Desktop Client, which handles most of this stuff for you, and more, and will satisfy most things you want to do with git through a much easier interface.
PS: A tip for the future, check out the commands that come up when you enter git help
. And before you use anything, use git help <command name>
, such as git help commit
.
Upvotes: 2
Reputation: 84453
You need to purge the files from your local and GitHub repositories. GitHub provides some step-by-step instructions using git-filter-branch, but the easiest way is by using BFG. For example:
bfg --delete-files \*.jpg
You can learn more about the BFG Repo-Cleaner, including features and options, from the project's web site.
Note that once you have purged the files from your repository, you will need to force-push your modified history to GitHub, and others will likely need to re-clone the new repository. The DAG of a filtered repository often makes it difficult (although not always impossible) for downstream clones to sync with the new history graph without re-cloning. However, YMMV.
Upvotes: 0
Reputation: 648
You can always use:
git rm nameofpic.jpg
git commit -m "Removing file from git repo"
Upvotes: 0