I\'m working first time on git. I have pushed my branch on github and it pushed all the library and documents into the github. Now what can I do and how can I use gitignore comm
git ignore is a convention in git. Setting a file by the name of .gitignore
will ignore the files in that directory and deeper directories that match the
patterns that the file contains. The most common use is just to have one file
like this at the top level. But you can add others deeper in your directory
structure to ignore even more patterns or stop ignoring them for that directory
and subsequently deeper ones.
Likewise, you can "unignore" certain files in a deeper structure or a specific
subset (ie, you ignore *.log but want to still track important.log) by
specifying patterns beginning with !
. eg:
*.log !important.log
will ignore all log files but will track files named important.log
If you are tracking files you meant to ignore, delete them, add the pattern to you .gitignore file and add all the changes
# delete files that should be ignored, or untrack them with
# git rm --cached <file list or pattern>
# stage all the changes git commit
git add -A
from now on your repository will not have them tracked.
If you would like to clean up your history, you can
# if you want to correct the last 10 commits
git rebase -i --preserve-merges HEAD~10
then mark each commit with e
or edit
. Save the plan. Now git will replay
your history stopping at each commit you marked with e. Here you delete the
files you don't want, git add -A
and then git rebase --continue
until you
are done. Your history will be clean. Make sure you tell you coworkers as you
will have to force push and they will have to rebase what they didn't push yet.