Post

12 Deleting and Renaming Files

12 Deleting and Renaming Files

Command:

1
2
$ cd checks/
$ ls -l

Code output:

1
2
3
4
5
total 8

-rw-rw-r-- 1 user user 659 Jul  9 19:28 disk_usage.py

-rw-rw-r-- 1 user user 659 Jul 15 21:43 processes.py

Command:

1
$ git rm process.py

Code output:

1
rm 'processes.py'

Command:

1
$ ls -l 

Code output:

1
2
3
total 4

-rw-rw-r-- 1 user user 659 Jul  9 19:28 disk_usage.py

Command:

1
$ git status

Code output:

1
2
3
4
5
6
7
On branch master

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)

        deleted: processes.py

Command:

1
$ git commit -m 'Delete unneeded processes file'

Code output:

1
2
3
4
5
[master 9939311] Delete unneeded processes file

 1 file changed, 24 deletions(-)

 delete mode 100644 processes.py

Command:

1
2
$ git mv disk_usage.py check_free_space.py
$ git status

Code output:

1
2
3
4
5
6
7
On branch master

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)

        renamed:    disk_usage.py -> check_free_space.py

Command:

1
$ git commit -m 'New name for disk_usage.py'

Code output:

1
2
3
[master 7d7167b] New name for disk_usage.py

 1 file changed, 0 insertions(+), 0 deletions(-)

Command:

1
2
$ echo .DS_STORE > .gitignore
$ ls -la

Code output:

1
2
3
4
5
6
7
8
9
10
11
total 20

drwxrwxr-x  3 user user 4096 Jul 15 22:15 .

drwxr-xr-x 19 user user 4096 Jul 15 16:37 ..

-rw-rw-r--  1 user user  659 Jul  9 19:28 check_free_space.py

drwxrwxr-x  8 user user 4096 Jul 15 21:52 .git

-rw-rw-r--  1 user user   10 Jul 15 22:15 .gitignore

Command:

1
2
$ git add .gitignore 
$ git commit -m 'Add a gitignore file, ignoring .DS_STORE files'

Code output:

1
2
3
4
5
[master abb0632] Add a gitignore file, ignoring .DS_STORE files

 1 file changed, 1 insertion(+)

 create mode 100644 .gitignore
This post is licensed under CC BY 4.0 by the author.