Git - 简单的使用与Github

Github:

Following the instructions to create repo.

Git on Linux(centos):

  1. download the latest GIT and build locally. 注意: centos6.5 默认的git版本是1.7.1, 该版本与github不兼容, 需要1.7.10以上的版本才可以.
  2. download tar ball from https://www.kernel.org/pub/software/scm/git/
  3. unzip file and perform the following command.

tar xzvf git-2.9.5.tar.gz

make configure
./configure --prefix=/usr
make install

//perform the following command if following issue occured.

//////////////////////////////////////////////////////////

//Can’t locate ExtUtils/MakeMaker.pm in @INC

yum install perl-ExtUtils-MakeMaker.x86_64

//MSGFMT    po/bg.msg make[1]: *** [po/bg.msg] Error 127

yum install tcl  build-essential tk gettext

// fatal: Unable to find remote helper for 'https' after perform command git clone ...

yum install libcurl-devel.x86_64


git --version

//check out

git clone https://github.com/<your ID>/<project>.git

//or (need add ssh key following

//https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

git clone git@github.com:<your ID>/<project>.git

 

//change file.

git add <changed/Added file>

git status

git commit -m "bala bala ..."

git pull  //like rebase

//如果出现冲突, 则会出现这样的错误.

CONFLICT (content): Merge conflict in src/Test.java
Automatic merge failed; fix conflicts and then commit the result.

//解决完冲突之后.

git add <conflict file>

git commit -m "resolve merge conflict."

git pull

 

git push  //this push into the master branch on github.

 

//branch list

git branch -a

//clone another branch example

git clone -b 2.0 git@github.com:<id>/<project id>.git <local alias>

[Merge branch into private branch]

Execute the following command in private branch:

      git merge origin/master

               you need reslove the confilit manually if any.

              [conflict when git pull]

git stash
git stash list       //list the stash
git pull
git stash pop      //ususally auto-merging

  

比对文件两次提交的difference:

git log -n 5 <path>

git diff <commit  #1> <commit #2> <path>

 

posted on 2018-02-09 16:52  bjfarmer  阅读(152)  评论(0编辑  收藏  举报