顾名思义移动(move )操作移动目录或文件从一个位置到另一个。Sampson 决定移动到src目录下的源代码。因此,修改后的目录结构看起来会像这样。
[sampson@CentOS project]$ pwd
/home/sampson/project
[sampson@CentOS project]$ ls
README string string.c
[sampson@CentOS project]$ mkdir src
[sampson@CentOS project]$ git mv string.c src/
[sampson@CentOS project]$ git status -s
R string.c −> src/string.c
?? string
要进行这些永久性更改,以便其他开发人员可以看到这一点,我们必须修改的目录结构推到远程存储库。
[sampson@CentOS project]$ git commit -m "Modified directory structure"
[master 7d9ea97] Modified directory structure
1 files changed, 0 insertions(+), 0 deletions(-)
rename string.c => src/string.c (100%)
[sampson@CentOS project]$ git push origin master
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 320 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To gituser@git.server.com:project.git
e86f062..7d9ea97 master −> master
在Byron 的本地资源库,抽取操作前,它会显示旧的目录结构。
[byron@CentOS project]$ pwd
/home/byron/byron_repo/project
[byron@CentOS project]$ ls
README string string.c
但是,抽取(pull )操作后的目录结构将得到更新。现在,Byron 可以看到该目录内的 src目录和文件。
[byron@CentOS project]$ git pull
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From git.server.com:project
e86f062..7d9ea97 master −> origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to 7d9ea97683da90bcdb87c28ec9b4f64160673c8a.
[byron@CentOS project]$ ls
README src string
[byron@CentOS project]$ ls src/
string.c