Git: 版本控制(4)
2019-03-28 本文已影响0人
柏龙
如何重新命名 (直接在文件系统上重命名)
- 添加一个新文件
git4.md文件 -
git status发现有新文件 -
git add .添加到暂存区 -
git commit -m 'add git4.md'提交到主目录 -
git status再次查看当前状态
On branch master
nothing to commit, working tree clean
- 右键编辑
git4.md文件,重新命名为git5.md -
git status查看当前状态 (会提示当前删除了git4.md, 有一个git5.md待添加)
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: git4.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
git5.md
no changes added to commit (use "git add" and/or "git commit -a")
-
git rm git4.md当前命令是告诉工作目录,我已删除了git4.md文件 -
git add git5.md添加当前重新命名的文件 -
git status查看状态(重命名git4.md->git5.md)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: git4.md -> git5.md
-
git commit -m '把git4.md文件重命名为git5.md'提交更名的文件,并添加备注 -
git push origin master提交到主分支 完成文件重新命名
使用 git mv 重命名
-
git mv git5.md git4.md把git5.md重命名为git4.md git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: git5.md -> git4.md
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: git4.md
git commit -m '使用git mv 重新命名了git5.md'
[master a3b182d] 使用git mv 重新命名了git5.md
1 file changed, 0 insertions(+), 0 deletions(-)
rename git5.md => git4.md (100%)
使用 git mv 移动文件
-
mkdir md创建一个文件夹 -
git mv git4.md md/把git4.md移动到md目录下面 -
git status提示一个重命名的文件(renamed)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: git4.md -> md/git4.md
git commit -m '把 git4.md 文件移动到 md文件夹里面'-
mkdir asset创建一个新文件夹 -
git mv md asset把md文件夹移动到asset文件夹里面
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: md/git4.md -> asset/md/git4.md