Git

Git is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people.

Installation

sudo apt install git

Configuration

Every git user should first introduce himself to git, by running these two commands:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

We can see all of the configuration items that have been set by typing:

git config --list

Usage

Create a new repository:

git init

Checkout a repository:

git clone /path/to/repository                 # local
git clone username@host:/path/to/repository   # remote

Add and commit:

git add <filename>
git add *
git commit -m "Commit message"

Status:

git status

Pushing changes:

git push origin master

Update local:

git pull

Diff with meld

To use meld as difftool, add to your ~/.gitconfig:

[diff]
    tool = meld
[difftool]
    prompt = false
[difftool "meld"]
    cmd = meld "$LOCAL" "$REMOTE"

Use git difftool in exactly the same way as you use git diff:

git difftool --dir-diff HEAD .
git difftool --dir-diff master fea-branch

Create a global .gitignore

You can create a global .gitignore file, which is a list of rules for ignoring files in every Git repository on your computer.

GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages:

curl https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore -o ~/.gitignore

results matching ""

    No results matching ""