R.A. Epigonos et al.

[git] リネームするにはgit mv。リモートにはコミットの後にpushしないと反映されません。

リネームするにはgit mvなのだけど、この後にpushしただけではリモートに変更が反映されない。必ずgit commitしてからgit pushすること。

まずは名前を変更する。lsで確認すると確かにtest.htmlがなくなり、index.htmlが出来ている。

$ git mv test.html index.html

この後にpushしてもリモートに変更は反映されない。

$ git push github
Enter passphrase for key '/home/**************************************':
Everything up-to-date

そこでcommitした後にpushする。これでリモートレポジトリの内容がローカルコピーと同じになったことになる。

$ git commit -a

rename file
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       renamed:    test.html -> index.html
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       **********
#       *****************
#       *************
#       ******************
".git/COMMIT_EDITMSG" 16L, 441C written
[master 50ce9a8] rename file
 1 files changed, 1 insertions(+), 1 deletions(-)
 rename test.html => index.html (75%)
$ git push github
Enter passphrase for key '/home/**************************************':
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 386 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:l/test.git
   078e960..50ce9a8  master -> master

考えてみれば当然で、git mvやgit addはファイル編集のようにローカルの変更はcommitして初めてpushされるというルールは常に有効なのである。

リファレンス

  1. git/git覚書 - TOBY SOFT wiki
  2. git mv - Google 検索
  3. 香川研究室でのGitの使い方
  4. git mv commit push - Google 検索

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2009-11-04T15:14:30+09:00
  2. Modified: 2009-11-04T15:14:30+09:00
  3. Generated: 2023-08-27T23:09:13+09:00