3

I am new to GitHub and I've started earlier this week.

I am uploading my Java projects to remote a repository as a backup.

I created a local repository within my bluej folder, which had .java and .class and .ctext files. However, I've realized after I pushed everything that I only needed .java files.

I made another new folder with the .java files only.

How do I make that new files "replace" my other local repository so that I can upload to the remote repository?
I tried using git remote origin master command, but because I did it on the previous folder, I cannot "replace" it with the new one.

Sorry if some of my terms are unclear, I only started GitHub a week ago.

Thank you for reading.

magicleon94
  • 4,887
  • 2
  • 24
  • 53
user132033
  • 31
  • 1
  • 1
    You don't need to create any new folder. Just remove the directory containing the .class files using `git rm`, then commit and push. Then add this directory to your .gitignore to avoid making the same mistake again and use `git add .gitignore`, then commit and push. – JB Nizet Sep 09 '17 at 16:18
  • Check out https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore – OneCricketeer Sep 09 '17 at 17:26

1 Answers1

1

You can use git rm to delete files from the repo, so you don't need to use the second copy to fix this.

Documentation for git rm

You can also use the .gitignore file to ignore files, so your class files don't get readded to git, you can also use the ignore generator to make a template ignore file.

.gitignore tutorial

.gitignore generator

jrtapsell
  • 6,719
  • 1
  • 26
  • 49