Git - Opération de déplacement

Comme son nom l'indique, l'opération de déplacement déplace un répertoire ou un fichier d'un emplacement à un autre. Tom décide de déplacer le code source danssrcannuaire. La structure de répertoire modifiée apparaîtra comme suit -

[[email protected] project]$ pwd
/home/tom/project

[[email protected] project]$ ls
README string string.c

[[email protected] project]$ mkdir src

[[email protected] project]$ git mv string.c src/

[[email protected] project]$ git status -s
R string.c −> src/string.c
?? string

Pour rendre ces changements permanents, nous devons pousser la structure de répertoire modifiée vers le référentiel distant afin que les autres développeurs puissent voir cela.

[[email protected] 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%)

[[email protected] 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 [email protected]:project.git
e86f062..7d9ea97 master −> master

Dans le référentiel local de Jerry, avant l'opération d'extraction, il affichera l'ancienne structure de répertoires.

[[email protected] project]$ pwd
/home/jerry/jerry_repo/project

[[email protected] project]$ ls
README string string.c

Mais après l'opération d'extraction, la structure du répertoire sera mise à jour. Maintenant, Jerry peut voir lesrc répertoire et le fichier présent dans ce répertoire.

[[email protected] 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.

[[email protected] project]$ ls
README src string

[[email protected] project]$ ls src/
string.c