DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

Click here to view code image


git mv (-f) (source) (destination)

For this command you supply a source argument and a
destination argument to indicate which file or directory
you want to change and where you want to move it.
(Moving in this case is considered the same as
renaming.) Keep in mind that when you use this
command, it also updates the index at the same time, so
there is no need to issue git add to add the change to
Git. You can use the -f argument if you are trying to
overwrite an existing file or directory where the same
target exists. The following example shows how to
change a filename in the same directory:


Click here to view code image


# ls
oldfile.py
# git mv oldfile.py newfile.py
# ls
newfile.py

Committing Files


When you commit a file, you move it from the index or
staging area to the local copy of the repository. Git
doesn’t send entire updates; it sends just changes. The
commit command is used to bundle up those changes to
be synchronized with the local repository. The command
is simple, but you can specify a lot of options and tweaks.
In its simplest form, you just need to type git commit.
This command has the following syntax:


Click here to view code image


git commit [-a] [-m] <"your commit message">

The -a option tells Git to add any changes you make to
your files to the index. It’s a quick shortcut instead of

Free download pdf