Git Basic command


=================================================NICE GIT TUTORIAL===============================================================
http://rogerdudler.github.io/git-guide/

======================================================GIT INSTALL COMMAND=================================================================
how to install git

$ sudo apt-get install git-all

=======================================================YOUR IDENTITY======================================================================
$ git config --global user.name "John Doe"
$ git config --global user.email "johndoe@example.com"

===============================================TO CHECK YOUR GIT SETTING==================================================================
git config --list

==========================================FOR A PARTICULAR FIELD FROM LIST==============================================================

git config user.name
git config user.email

=================================================GETTING HELP VERB=======================================================================
$ git help <verb>
$ git <verb> --help
$ man git-<verb>

LIKE----> $ git help config


==============================================TO DOWNLOAD FILE CLONE FROM TERMINAL=======================================================

$ git clone https://github.com/libgit2/libgit2

============================================== TO CHECK THE STATUS OF THE FILE ===========================================================
$ git status

============================================== CHANGE USERNAME AND EMAIL================================================================
$ git config --global user.name "swati"
$ git config --global user.email "abc@gmail.com"


=================================================IMPORTANT  INFO=============================================================================
how to install git

$ sudo apt-get install git-all

git config --global user.name "mukesh"

to check
git config user.name

git config --global user.email webexpertz.ntf@gmail.com

to check
git config user.email
$ opt/lampp/htdocs
git clone http://mukesh@bacchus.namhost.com:8080/r/ba.git

git clone http://mukesh@bacchus.namhost.com:8080/r/ba-DB.git (clone files from client res)

git clone http://mukesh@bacchus.namhost.com:8080/r/ba-FILES.git

=============================================HOW TO GO IN OUR LOCAL DIRECTORY============================================================
$ cd /opt
/opt$ cd lampp/htdocs

LIKE--> satyam:~$ cd /opt
       satyam:/opt$ cd lampp/htdocs
        satyam:/opt/lampp/htdocs$ git config user.name
        satyam:/opt/lampp/htdocs$ git clone https://github.com/swatichouhan012/data.git
       satyam:/opt/lampp/htdocs$ cd data("PROJECT NAME")
        satyam:/opt/lampp/htdocs/data$ git status
        satyam:/opt/lampp/htdocs/data$ git add test.php(file name)
        satyam:/opt/lampp/htdocs/data$ git commit -m "add test file"

        PUSH FILE FROM TERMINAL
        satyam:/opt/lampp/htdocs/data$ git push origin master
       
        PULL FILE FROM GIT
        satyam:/opt/lampp/htdocs/data$ git pull origin master      


============================================== PUSH FILE FROM TERMINAL=================================================================

$ git push origin master(BRANCH)

===============================================PULL FILE FROM GIT====================================================================

$ git pull origin master(BRANCH)

==============================================MOST COMMONLY USED GIT COMMAND========================================================

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

============================================DIFFERENCE BETWEEN (cd ..) and (cd /)=====================================================

cd .. --> used if you want to back from only 1 directory.
cd /  ---> used if you want to come on directly on home.


==============================================TO CREATE BRANCH IN GIT=============================================================================
$ git checkout -b <branch_name>

================================================SWITCH BRANCH IN GIT===================================================================
$ git checkout <branch_name>

====================================================DELETE BRANCH ====================================================================
$ git branch -d <branch_name>
like --> $ git branch -d slave

==================================================MERGE BRANCH "DATA FILES" TO CURRENT BRANCH=========================================
1) switch to your "master" branch.
2) apply this command ----> $ git merge <branch_name>
3) simply push your required file
4) check git status

===============================================TO CHECK FILE LIST IN FOLDER=============================================================
1) GO INTO FOLDER AND JUST APPLY --> $ ls

============================================TO CHECK GIT REPOSITORY HISTORY=============================================================

$ git log

$ git log --author "<author name>"             (TO CHECK REPO HISTORY OF PARTICULAR AUTHOR)

$ git log --pretty=oneline                     (To see a very compressed log where each commit is one line:)


======================================================================================================================================

===============================================PUSH PROJECT FOLDER ON GIT================================================================
1) $ git init
2) $ git add -A
3) $ git commit -m "message"
4) $ git push origin master<branch_name>


============================================= CHANGE GIT COMMIT MESSAGE BEFORE PUSHING FILE============================================
$ git commit --amend -m "<your new message>"


==================================================GIT STASH (HIDE FILE FOR SOME TIME)==================================================

1)WHAT IS STASH AND WHY WE USED IT ->

when we are working on some thing nd the requirement is work on others on same file and we want to only

==============================================TO CHECK PHP VERSION================================================================
$ sudo php --version

===============================================FOR ACCESS ALL COMMANDS FROM ROOT=====================================================
$ su


=========================================== STOP ANOTHER WEB SERVER===================================================================
$ sudo /etc/in

---------
~$ sudo /etc/init.d/apache2 stop /opt/lampp/bin/phpize

THEN RESTART YOUR SERVER


=============================================CHECK UBUNTU VERSION FROM TERMINAL==================================================
$ lsb_re
Previous
Next Post »