git 安装,clone和提交

来源:互联网 发布:双十一淘宝购物技巧 编辑:程序博客网 时间:2024/06/08 12:22

一 :linux git install 

configure in Gerrit:  

Step for the user who don’t have git account, but will work on android projects:

  1. git 初次 config:
    git config --global user.email "fabc@126c.om "
    git config --global user.name "fabc" 
  2. Run “ssh-keygen -t rsa”
  3. login to http://1.2.3.4:8080/ with your windows account.

Find your name in the upper right corner, click settings





4.  Make sure you can login gerrit web page with your account

$ ssh -p 29418 fabc@1.2.3.4

  ****    Welcome to Gerrit Code Review    ****
  Hi fabc, you have successfully connected over SSH.
  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://fabc@1.2.3.4:29418/REPOSITORY_NAME.git

notes: REPOSITORY_NAME.git need replace 


5  login http://1.2.3.4:8080 ; choose  project –--list-- --MediaRelayEngine

clone with commit-msg hook

git clone ssh://fabc@1.2.3.4:29418/MediaRelayEngine&& scp -p -P 29418 fabc@1.2.3.4:hooks/commit-msgMediaRelayEngine/.git/hooks/


git 原理: local work; push gerrit; gerrit submit git

6 git checkout -b ice_feature origin/ice_feature (switch  ice_feature branch)(已经下载下来了,没有switch,所以git branch的时候没显示出来)

7  git branch (check which branch is on)

8 !
提交
git pull
git diff 

git commit -a -m "ice setting"  (别忘了a,append,m是commit message;)

([ice_feature b96837a] add nodejs debug tool client
 6 files changed, 539 insertions(+), 15 deletions(-)   

这是正确的返回output  )

git push origin HEAD:refs/for/ice_feature (HEAD is local; refs is remote; ice_feature 替换成自己的branch)

(remote:   http://172.21.110.41:8080/1489 

正确的output,会给出code review的web)

9  code review

http://1.2.3.4:8080

在open中,选中提交的package。进行review


10 不要采用和svn一样的做法,将本地文件a.cpp删掉,用git pull下载代码.

这样对git来说,认为是user向要delete这个文件,而不是pull这个文件,当user commit之后真变成在git 库上delete这个文件了.

如何恢复呢?

git 恢复到当前库上的new version
git reset --hard 6b33994a40e3ccea34e030767d68fd41bca5c89d 
(change id is the newest submitted commitid)


11 其他git 常用命令

git status/ git log

二: windows install git

注意tortoisegit 和普通git 不同。

所以安装git的时候,选择不要安装与tortoisegit有关的任何东东.

原创粉丝点击