刚上传了vs项目到github,但是忘记搞gitignore文件,导致项目上传的体积太大,
现在不知道怎么办了?
删除里面所有文件,写好gitignore文件后重新commit然后push?
大家讲道理2017-04-22 09:01:48
git rm -r --cache . git add . git commit -m "gitignore working"
The first time I submitted a question, the system hadn’t reviewed it for a long time, so I searched it. Actually I found the answer from stackoverflow last night. But thank you all anyway. http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring
阿神2017-04-22 09:01:48
Please enter link description
There is also an option to rewrite history if you want to scriptably modify a large number of commits - for example, to change email addresses globally or remove a file from all commits. This command is filter-branch, and it will modify your history extensively, so you probably shouldn't use it unless your project is not yet public and no one else is working on the commit you intend to modify. Still, this one can be very useful. You'll learn some common uses to get an idea of its capabilities.
Remove a file from all commits This happens often. Some people use git add . without thinking and accidentally commit a huge binary that you want to delete from everywhere. Maybe you accidentally committed a file containing a password and you want to make your project open source. filter-branch will probably be the tool you use to clean up your entire history. To remove a file named password.txt from the entire history, you can use the --tree-filter option on filter-branch:
$ git filter-branch --tree-filter 'rm -f passwords.txt' HEAD Rewrite 6b9b3cf04e7c5686a9cb838c3f36a8cb6a0fc2bd (21/21) Ref 'refs/heads/master' was rewritten The --tree-filter option will execute the specified command and then resubmit the results each time the project is checked out. In this example, you would delete a file named password.txt from all snapshots, regardless of whether it exists. If you want to delete all editor backup files that were accidentally committed, you can run a command like git filter-branch --tree-filter 'rm -f *~' HEAD.
You can watch Git rewrite the directory tree and commit, then move the branch pointer to the end. A better approach is to do this on a test branch and then hard-reset your master branch after you're sure the product is really what you want. To run filter-branch on all your branches, you can pass --all to the command.
Set a subdirectory as the new root directory Suppose you have completed an import from another code control system and have some meaningless subdirectories (trunk, tags, etc.). If you want the trunk subdirectory to become the new project root directory for each submission, filter-branch can also help you do it:
$ git filter-branch --subdirectory-filter trunk HEAD Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f (12/12) Ref 'refs/heads/master' was rewritten Now your project root directory is the trunk subdirectory. Git will automatically delete commits that do not affect this subdirectory.
阿神2017-04-22 09:01:48
Provide a relatively novice solution: Enter the project-->Setting-->Delete this Repository and then create a new repo and you're done
阿神2017-04-22 09:01:48
You need to use
git reset
For details, you can view Git’s undo operations - reset, checkout and undo: http://www.liuhui998.com/4_9.html
Suppose you want to cancel all changes and return to the most recent commit. The command is as follows:
$ git reset --hard HEAD
天蓬老师2017-04-22 09:01:48
Project homepage——>Settings——>Delete this Repository——>Resubmit Ok, I’m not very good at using it either
天蓬老师2017-04-22 09:01:48
Back up first or commit first (bloody lesson)
git reset --hard
YOUR HEAD
How to query the head of the submitted record
git reflog || git log