OpenStack git cmd

文件流转的三个工作区域:Git 的工作目录,暂存区域,以及本地仓库。

基本的 Git 工作流程如下:

  • 在工作目录中修改某些文件。
  • 对修改后的文件进行快照,然后保存到暂存区域。
  • 提交更新,将保存在暂存区域的文件快照永久转储到 Git 目录中。

1.安装git和git-review

 apt-get install git

 apt-get install git-review

2.创建分支

建立分支是你创建代码的独立版本的动作,独立于你的主干分支。默认地,每次你提交到Git的文件都会被储存到“master(主干)”分支。
现在我们来说说,你想要向项目里添加一个功能,但你想要能够回滚到现在版本,以防出现差错,或者你决定要放弃这个功能。这就是你创建分支的时候了。

创建并同时切换到你新建的分支命令:

  git checkout -b new_feature

或者,你可以先创建一个分支然后手动切换:

  git branch new_feature

    git checkout new_feature

3.查看当前branch状态

  git status

4.添加当前branch的代码修改到本地暂存区域

  git add *

  git add .

5.查看版本的log记录

  git log

6.查看git的配置

git config --list

git config -l

user.name=xiangxinyong
user.email=xiangxinyong@huawei.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://git.openstack.org/openstack/murano
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
remote.gerrit.url=https://xianxinyong:CPhXYJBLzg6u@review.openstack.org/openstack/murano.git
remote.gerrit.fetch=+refs/heads/*:refs/remotes/gerrit/*

7.修改git配置项

git config --global user.name xiangxinyong

8.添加或修改git的message

添加:git commit -a -F .git/message  

修改:git commit --amend -a -F .git/message

9.添加和设置gerrit(可选)

  当端口29418被封的时候需要按以下步骤设置:

首先,需要登录review.openstack.org,然后在Settings -> HTTP Password里,生成一个HTTP密码,应该是一个大小写加数字的随机字符串。

git remote set-url gerrit https://username:http-password@review.openstack.org/openstack/nova.git命令把ssh修改成https方式,当然也可以用http

git remote add gerrit https://username:http-password@review.openstack.org/openstack/nova.git

备注:上面字符串中的用户名/密码改成你的gerrit用户名和上一步生成的HTTP密码。

10.提交代码到远程代码库

  git review

Else:

    (1)git diff 查看本地修改的具体内容

    (2)git branch -d branchname 删除本地分支

    (3)git checkout . 取消本地所有修改

    (4)git pull https://git.openstack.org/openstack/murano 获取最新代码

    (5)git rebase -i 本地重新建立依赖关系,删除掉所有的依赖描述,只保留当前patch的描述,

        Ctrl+X,Y, Enter.

    (6)git review -d 1111 获取指定的远程版本

  (7)git show-ref YOUR_TAG

    (8)refs/heads/stable/mitaka表示本地分支

    (9)refs/remotes/origin/stable/mitaka使用git checkout stable/mitaka

    (10)refs/tags/kilo-eol使用git checkout -b stable/kilo kilo-eol

TryStack国内镜像站:

原文地址:https://www.cnblogs.com/edisonxiang/p/4668195.html