gitでFile Changed 数が5000になってしまった問題

既にやったこと。

 

操作コマンド

 

master branchにて
 git add .gitignore   .gitignoreにgit管理しないファイルを指定。
 git commit
 git push origin master
new-user branchにて
 git rebase master
master branchにて
 git rm -r --cached --ignore-unmatch vendor/bundle/ 
 git add .
 git commit
 git push origin master
new-user branchにて
 git rebase master

 

次に 施行したこと

gem reset でgit resetした後にgit statusでgemのファイルが赤く表示されている(コミットされていない状態)に戻す。

 

git logでハッシュ値を確認。
git reset --hard 昔のコミットのハッシュ値

 

参考

https://qiita.com/shuntaro_tamura/items/db1aef9cf9d78db50ffe

 

 

delete mode 100644 vendor/bundle/gems/spring-2.1.0/lib/spring/client/command.rb

......

```sh
$git push origin master
To https://github.com/xxx/yyy.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/yyy.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> new-user

$git pull origin master
From https://github.com/xxx/yyy
* branch master -> FETCH_HEAD
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.
$git commit "gitignore"
fatal: cannot do a partial commit during a merge.
$git commit "gitignorew"
fatal: cannot do a partial commit during a merge.
$git push origin master
To https://github.com/xxx/yyy.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/yyy.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$git pull origin master
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
$git status
On branch new-user
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)

Unmerged paths:
(use "git add <file>..." to mark resolution)

both modified: .gitignore

no changes added to commit (use "git add" and/or "git commit -a")
$git branch
master
* new-user
$ git checkout master
.gitignore: needs merge
error: you need to resolve your current index first
$git branch
master
* new-user
$git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?
$git add .
$git commit
[new-user ad9868f] Merge branch 'master' of https://github.com/xxx/yyy into new-user
Commiter:AAA
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

$git push
fatal: The current branch new-user has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin new-user

$git push origin new-user
To https://github.com/xxx/yyy.git
! [rejected] new-user -> new-user (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/yyy.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$git branch …なぜかnew-userになっていた。 

master
* new-user
$git pull origin new-user
From https://github.com/xxx/yyy
* branch new-user -> FETCH_HEAD
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/yarn.lock deleted in HEAD and renamed to yarn.lock in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of yarn.lock left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/postcss.config.js deleted in HEAD and renamed to postcss.config.js in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of postcss.config.js left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/webpacker.yml deleted in HEAD and renamed to config/webpacker.yml in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of config/webpacker.yml left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/webpack/test.js deleted in HEAD and renamed to config/webpack/test.js in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of config/webpack/test.js left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/webpack/production.js deleted in HEAD and renamed to config/webpack/production.js in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of config/webpack/production.js left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/webpack/environment.js deleted in HEAD and renamed to config/webpack/environment.js in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of config/webpack/environment.js left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/webpack/development.js deleted in HEAD and renamed to config/webpack/development.js in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of config/webpack/development.js left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/bin/webpack-dev-server deleted in HEAD and renamed to bin/webpack-dev-server in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of bin/webpack-dev-server left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/bin/webpack deleted in HEAD and renamed to bin/webpack in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of bin/webpack left in tree.
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/babel.config.js deleted in HEAD and renamed to babel.config.js in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of babel.config.js left in tree.
Removing app/views/users/new,html.erb
Removing app/views/toppages/index.htmlj.erb
Removing app/views/layouts/_footer.html.rb
Removing app/assets/stylesheets/application.css
CONFLICT (rename/delete): vendor/bundle/gems/thread_safe-0.3.6/.rspec deleted in HEAD and renamed to .rspec in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of .rspec left in tree.
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
CONFLICT (rename/delete): vendor/bundle/gems/webpacker-4.0.7/lib/install/config/.browserslistrc deleted in HEAD and renamed to .browserslistrc in 270614954659bc66bd7dcecc185a60e128b26e5e. Version 270614954659bc66bd7dcecc185a60e128b26e5e of .browserslistrc left in tree.
Automatic merge failed; fix conflicts and then commit the result.
$git push origin master
To https://github.com/xxx/yyy.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/yyy.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
$git status
On branch new-user
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)

Changes to be committed:

new file: .vscode/launch.json
modified: Gemfile
modified: Gemfile.lock
deleted: app/assets/stylesheets/application.css
new file: app/assets/stylesheets/application.scss
modified: app/controllers/application_controller.rb
renamed: app/controllers/toppages_contoroller.rb -> app/controllers/toppages_controller.rb
modified: app/controllers/users_controller.rb
modified: app/javascript/packs/application.js
new file: app/views/layouts/_footer.html.erb
deleted: app/views/layouts/_footer.html.rb
modified: app/views/layouts/_navbar.html.erb
modified: app/views/layouts/application.html.erb
modified: app/views/shared/_error_messages.html.erb
new file: app/views/toppages/index.html.erb
deleted: app/views/toppages/index.htmlj.erb
deleted: app/views/users/new,html.erb
new file: app/views/users/new.html.erb
modified: app/views/users/show.html.erb
modified: config/application.rb
modified: config/routes.rb
new file: db/migrate/20190913090310_create_users.rb
new file: db/schema.rb
modified: package.json
new file: spec/features/toppages_spec.rb
new file: spec/features/user_pages_spec.rb
new file: spec/rails_helper.rb
new file: spec/spec_helper.rb

Unmerged paths:
(use "git add <file>..." to mark resolution)

added by them: .browserslistrc
both modified: .gitignore
added by them: .rspec
added by them: babel.config.js
added by them: bin/webpack
added by them: bin/webpack-dev-server
added by them: config/webpack/development.js
added by them: config/webpack/environment.js
added by them: config/webpack/production.js
added by them: config/webpack/test.js
added by them: config/webpacker.yml
added by them: postcss.config.js
added by them: yarn.lock

$git add.
git: 'add.' is not a git command. See 'git --help'.

The most similar command is
add
$git add .
$git commit -m "conflict"
[new-user 72bae13] conflict
Commiter:AAA
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

$git push origin new-user
Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 1.03 KiB | 1.03 MiB/s, done.
Total 8 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 3 local objects.
To https://github.com/xxx/yyy.git
2706149..72bae13 new-user -> new-user
$git status
On branch new-user
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: .gitignore

no changes added to commit (use "git add" and/or "git commit -a")
$git add .
$git commit -m "ignore"
[new-user 5cd15d4] ignore
Commiter:AAA
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

1 file changed, 17 deletions(-)
$git push origin new-user
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 312 bytes | 312.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/xxx/yyy.git
72bae13..5cd15d4 new-user -> new-user