Initialize git to a project directory

$ git init


Clone a repository

$ git clone

#Clone in the current directory (without creating any directory)
$ git clone .


Add a project to repository

$ git add .


Commit modified files to the repo.

#First you need to add than commit.
add : $ git add --all [all files to commit]
      $ git add test.txt [single file to commit]
      $ git add test.txt test2.txt test3.txt [multiple files to commit]
      $ git add git-*.txt [multiple files to commit with pattern matching]

commit : $ git commit -m "message here"

#Commit in a single command
$ git commit -a -m "message here" [which file to add and commit condition will be here]


Pull the changes in the local server

$ git pull


Listing of all branches

$ git branch --list


Create branch

create branch
$ git branch [new_branch_name]

Switch branch
$ git checkout [new_branch_name]

create and switch branch in one command
$ git checkout -b [new_branch_name]


Add a new remote for your branch :

$ git remote add [name_of_your_remote] 
Push changes from your commit into your branch :

$ git push origin [name_of_your_remote]
Update your branch when the original branch from official repository has been updated :

$ git fetch [name_of_your_remote]
Then you need to apply to merge changes, if your branch is derivated from develop you need to do :

$ git merge [name_of_your_remote]/develop
Delete a branch on your local filesystem :

$ git branch -d [name_of_your_new_branch]
To force the deletion of local branch on your filesystem :

$ git branch -D [name_of_your_new_branch]
Delete the branch on github :

$ git push origin :[name_of_your_new_branch]
$ git push origin --delete [name_of_your_new_branch]


Merge branch

$ git merge [new_branch_name]
Options : 
Perform the merge and commit the result. This option can be used to override --no-commit.

With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and further tweak the merge result before committing.


git checkout origin/alpha httpdocs/include/config.php
download file from server

git commit -m 'my notes' path/to/my/file.ext
git commit -m 'my notes' -- path/to/my/file.ext
commit single file
create and Switched to a new branch
create : $ git branch iss53
switch : $ git checkout iss53

Do above in one command : $ git checkout -b iss53
git merge

$ git checkout master

Switched to branch 'master'

$ git merge iss53

git switch to branch where you have to merge.
git merge --no-commit feature/feedback_popup_form

git reset HEAD httpdocs/include/config.php
git checkout -- httpdocs/include/config.php
git push origin alpha

  • git
  • command