DEV Community

Kamil R Aliyev
Kamil R Aliyev

Posted on

Notes on Git Basics

Basic Commands

    $ git --version # Git version
    $ git init  # Initialize Local Git Repo
    $ git add <file/files/. > # Adding file/files/all to the staging area or index
    $ git rm --cached <file/files/. > # Remove file or files from the staging area
    $ git status # Check Status of Working Tree ( show differences between working tree and the staging area)
    $ git commit # Commit Changes to the Index
    $ git push # push to remote repos
    $ git pull # pull latest from remote  repo
    $ git clone # Clone repo into new directory

Some Config Options

$ git config --global user.name 'Your Name'
$ git config --global user.email 'your email'

Examples

    $ git add *.html # add all html files to the stage
    $ git commit -m 'short message' # commiting with short message

.gitignore file

 $ touch .gitignore
/dir_name
file.txt 
*.txt 


Branching

Creating Branch

        $ git branch BranchName

Changing Branch

    $ git chechkout BranchName

Merging

    $ git merge BranchName

Git adding remote

    $ git remote add origin https://github.com/tratata
    $ git remote
    $ git push -u  origin master
    $ git pull

Top comments (0)