1

I'm new to github and have been working on a group project for school. Recently it turned out we were missing some stuff and nothing was organized (every file was just uploaded into the main directory) so I removed everything using a command in the github shell. Then I proceeded to make files and organize all the code and re-upload and store everything in there.

However, when I did this, I had to keep committing every time I made a new folder and stored a bunch of files in it. I would like to keep the changes made during those commits (because I created folders and re-uploaded the stuff), but I want to remove those commits from the history because they are cluttering up the project.

Is this possible, and if so can you please walk me through the steps. Also I'm new to github so I don't know much.

Here is a picture of the ones I want to remove from my history because they are cluttering up the screen (see red marks):enter image description here

Thanks :)

EDIT: PLEASE NOTE: I don't want to revert the changes, I just want all those history to be removed because they are cluttering up the commit history.

StacksAndParsing
  • 119
  • 1
  • 11
  • Just delete the files locally, commit and push. You should be safe having the files remain in your history assuming they are all text or source code and not binaries. – Tim Biegeleisen Apr 30 '17 at 05:49
  • Possible duplicate of [How can I merge two commits into one?](http://stackoverflow.com/questions/2563632/how-can-i-merge-two-commits-into-one) – Tatsuyuki Ishi Apr 30 '17 at 05:59
  • @TimBiegeleisen but I want to get rid of these commit notes in the picture, not the actual project – StacksAndParsing Apr 30 '17 at 07:05
  • On the following screen, I tried changing everything but the first and last to squash instead of pick but I get the error `error: cannot 'squash' without a previous commit` https://imgur.com/a/K328t – StacksAndParsing Apr 30 '17 at 07:39

1 Answers1

0

You should use:

git rebase -i  HEAD~14

To rebase and squash your unwanted commits. Just use p to mark the last commit and use f to mark the unwanted commits for squashing it with the previous commits. This will remove it from commit log keeping the changes.

More info: https://git-scm.com/book/gr/v2/%CE%94%CE%B9%CE%B1%CE%BA%CE%BB%CE%B1%CE%B4%CF%8E%CF%83%CE%B5%CE%B9%CF%82-%CF%83%CF%84%CE%BF-Git-Rebasing

Gautam Krishna R
  • 2,388
  • 19
  • 26