Thursday, May 30, 2013

Git Basic Commands

git status                                         -    display changes
git checkout .                                  -    clear all files from last edit
git checkout <file> <file>                -    clear specified files last edit only
git pull                                             -    pull all files from server
git diff > <file>                                 -    write whole diff on new file
git diff <file> > <file>                       -    write specific file diff on new file
git diff <file> <file> > <file>             -    write more than one files diff on new file
git add .                                           -    add all files to client from buffer 
git commit -m “msg”                       -    record local changes to local repository
git push                                           -    push the local repository recorded code(done by git commit) to server repository.
git add <file>                                   -    add untracked file to buffer
git diff --cached >> <file>               -    append new file changes to exist diff file.
git log                                              -    List commits
ctrl l or clear                                   -    clear screen
git diff --diff-filter=D >> <file>         -    Append all deleted file details to diff
git help <verb>                               -    Detail about specific verb
git reset HEAD <file>                     -    Move file from staged to unstage (Note: When new file added and send for push by       diff(used --cached), and if you try to pull from repository first you use ‘git reset HEAD <file>’ and then delete that file manually, then only you can pull.)
ctrl + ins (or) ctrl + shift + c           -    Copy
shift + ins (or) ctrl + shift + v         -    Paste
Q                                                    -    Go to new cmd
ctrl + c                                            -    Stop / Cancel current process
patch -p1 --dry-run < <diff_file>    -    List affecting file if we add or integrate specific diff file.
patch -p1 < <diff_file>                   -    Add or integrate specific diff file
git clone https://site.com/dir/project.git <localfolder> - Clone git from server using https
(Note: First open terminal and go to local folder where you want to pull and use above command to copy/ clone project to local.)
git checkout <branch_name>      -    Will switch to specified branch.
git branch <branch_name>          -    Will create a branch.
git checkout -b <branch_name>  - Will create and switch to branch at the same time.

Note: Be care full when using red marked comments above. Because it may affect your codes permanently, and most of the time will only used by admin of the project.

No comments:

Post a Comment

Learn JavaScript - String and its methods - 16

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>String and it's methods - JS&l...