git command

Getting Started
way1) clone form existing repository

$ git clone <git_url> <directory_to_create>
$ git add .
$ git commit -m "A change to my application"
$ git push

NOTE:

if clone https instead of ssh, github will continue ask for username and password.

To change that to ssh, the following command will change the config in `.git/config` file.

git remote set-url origin git@github.com:username/repo.git

NOTE :
If `https://` the `url` parameter in `remote origin` section in `.git/config` will begin with https://.
If `ssh`, there will be no `https://`

[remote "origin"]
url = https://

Way2) init own repository

git init
git remote add origin git@github.org:repo.git

View uncomiited status

git status

View log

git log

Git pull

git fetch --process --prune origin

NOTE : git pull = git fetch + git merge
ref : http://stackoverflow.com/questions/292357/what-are-the-differences-between-git-pull-and-git-fetch

Add Branch

git branch --no-track branch_name
git checkout branch_name
git commit

Checkout Branch

git checkout -b branch_name

View status of the file 

git status
xxx modified

Add/Commit/Push

git add filename

git commit -m 'comment here'

git push origin banch_name

Merge Branch

git merge --no-commit -no-ff branch_name
git commit

Check push privilege

In git folder,

git remote -v

Tag

git tag -a v1.4 -m "my version 1.4"

Show which file is diff between branch

git diff --name-status master..branchName

List all the different

git diff master..develop

ref : http://stackoverflow.com/questions/19814800/in-git-how-can-i-see-the-diff-from-master-to-develop

NOTE :

cd to windows drive is like this

cd /c/Program\ Files/Docker\ Toolbox

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s