Git server commands

Git server commands

Git server commands

GIT is a power full sub version system. You can Update, commit  data to/from server

Creating new git repository: GIT is a power full
Mkdir dir1
cd dir1
git init
cd ..
cp -ra wordpress/* dir1
cd dir1
git add .
git commit -m "first commit"

Committing code in GIT repo

git add filename
git commit -m "msg" filename

git-config name value            #set name and value
git-config name                    #get current value
git-config -l                          #get all values

GIT  encourages branching:
Create a branch:

git-checkout -b topic-name master

Delete branch

git-branch -d topic-name

Merging branches and getting conflict:

Two different people work on two different branches:

A works on branch A:

git checkout master
git checkout -b branchA master

B wants to work on his branch:

git checkout master
git checkout -b branchB master

Now the situation is as follows:

/          \
branchA    branchB

Now we can do two things: Merge and Rebase:


/        \
branchA    branchB
\         /


A has completed his work he will merge his branch with master and then delete his branch

git checkout master
git merge branchA
git branch -d branchA

B has now completed his work and he want to merge and then delete his  branch

git checkout master
git merge branchB


B will resolve the conflict and then merge the branchB with master code. Then

git branch -d branchB


X        \
barnchA — branchB

we relocate the parent of branchA with branchB and pretend that we checkout the branch from branchB.

Checking Logs:


git-log -p                       # print difference b/w revisions
git-log –stat                  # statistics
git-log file1 file2 file3      # log for specified files

Checking differences

git-diff                                           #  difference b/w commited and current code
git-diff HEAD                                 #  difference b/w
git-diff –cached                             #
git-diff OTHERBRANCH                 # difference b/w current and OTHER BRANCH
git-diff BRANCH1 BRANCH2          # difference b/w BRANCH1 and BRANCH2

Working with others:

git-clone                                       #to  create the copy of remote directory

git clone ssh://

git-pull                                          #to get changes from remote directory

git-push                                        #to send changes to remote directory

git-fetch                                        #updating our repo with remote repo.