-
Mark HOEBEKE authored79a91506
Git Command Line Basics
All Git commands start with the git
"main" command followed by a keyword matching the Git operation to be performed. Running Git commands only works inside folders that belong to a (local) Git repository.
Trying to run Git commands outside a Git repository folder will generate an error message.
This index lists all the available commands with links to extensive documentation.
Displaying information about a local repository
The git status
command displays information about the current status of the local repository:
- What is the current branch ?
- If it is related to a remote branch, have any modifications been made on either side ?
- What has happend to the files and folders of the local repository ?
Important note
- By default Git ignores files with a predefined list of suffixes, considering they are generated by some complation process, and should not be included in a Git repository. These files will not show up in the output of
git status
.
On a freshly cloned repository, the output of git status
looks like:
The git log
command details all the operations that have been performed on the current branch since it was created, crouped by commits. git log
provides many many options to customize the output.
On the freshly cloned example repository, the output of git log
looks like:
Making changes to a local repository
You can make any changes to a local repository (adding, removing, renaming files and folders, editing files). Git will take note of what has changed and you can always use git status
to view the changes.
For example, after editing the contents of the README.md
file, git status
will display:
Notice that Git mentions that the README.md
and the imaginary.md
files have been modified but has not been staged for commit. The same is true for the newly added images/bigfoot.jpeg
file. This means that even if you try git commit
right now, nothing will be commited.
Notifying Git which changes have to be included in the next commit.
Git has to be explicitely made aware of what changes you want to include in the next commit.