0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[git]ファイルを指定して変更を戻す

Posted at

実現したいこと

複数の変更をpushしている時、一部のファイルのだけ前のコミットの状況に戻したい。

使用コマンド

git checkout で実現できた。引数は戻りたいコミットのidと戻したいファイル名。

git checkout {commitID} {fileName}

実際に打ったコマンド

git checkout HEAD@{5} app/Http/Controllers/User/UserController.php
XXXMacBook-Pro:backend XXX$ git add .
XXXMacBook-Pro:backend XXX$ git commit -m"BookingControllerの変更取り消し"
[XXX 14f37267] UserController.phpの変更戻す
 1 file changed, 16 insertions(+), 12 deletions(-)
XXXMacBook-Pro:backend XXX$ git push origin branch
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 756 bytes | 756.00 KiB/s, done.
Total 7 (delta 6), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (6/6), completed with 6 local objects.
To https://XXX.git

無事pushまでできました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?