GIT BASICS: MAJOR COMMANDS

created: 25.10.2018 10:32

edited: 30.10.2018 08:48

back

config

Sets the configuration values. The email address or the username can be defined. With --global you define this configuration value global for the system.

bash
git config --global user.name "John Smith"
git coniig user.email "john@provider.com"

init

Initializes a directory as a git directory. Creates a hidden folder (.git).

bash
git init

clone

Using this command, you clone a git repository from a server to your local computer.

bash
git clone https://github.com/torvalds/linux.git

add

Add files to the git directory (files to be committed later). With the 'git add .'- command all files that are currently in the directory will be added to the version control.

bash
git add .

rm

Just like the add command, only files are deleted from the repository in this case - the files will not be deleted from your system.

bash
git rm file.txt

commit

Takes all changes, adds new files or deletions and saves it to an object.

bash
git commit -m "commit message"

status

Checks the state of the files in the git directory.

bash
git status

branch

List all branches.

bash
git branch

checkout

Checkout to a branch.

Bash
git checkout master

reset

Resets the directory to the state of the last commit.

bash
git reset

fetch

If you reset your local changes to the state of the master branch on the server, the command would be 'git fetch master'.

bash
git fetch master

pull

Combination of fetch and merge. Takes the changes of the server and guides them with their own changes together.

bash
git pull

push

Uploads all local commits to the repository server.

bash
git push