首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >git使用说明

git使用说明

作者头像
绿巨人
发布2018-05-16 18:02:38
7610
发布2018-05-16 18:02:38
举报

git使用说明

配置git的环境变量

# set git variables 
git config --global user.name "<your name>"
git config --global user.email "name@email.com"

# query the value of user.name
get config user.name

复制一个Repository到客户端

git clone https://github.com/apache/spark.git
cd spark

创建一个Repository

# create git repository on the client
mkdir myRepos
cd myRepos
git init

增加一个文件

# create a file
touch README.md

# add the file into the client repository
git add README.md

# record changes to the client repository
git commit -m "my changes"

# add a remote
git remote add origin https://github.com/apache/spark.git

# Deliver client changes to the server repository
git push -u origin master

Git Workflow

We are using a simplified version of Gitflow workflow. Here is some information about Gitflow:

High-level tutorial from Atlassian Original blog about Gitflow

  • Here is a transcript showing how to make a change from start to finish using this workflow:
git remote show origin                  # Check your configuration before starting
git status                              # Use this command frequently
git checkout -b new-branch-name develop # Creates a new local branch based on develop
  • Now change whatever files you need to, and then make use of some of these commands as your work progresses:
git add README.md                       # Add your changed files to the staging area
git diff --staged                       # Compares the staging area to your local repo
git commit -a                           # Commits changes in staging area to local repo
git log --name-status --since=2.days    # Make sure the history looks as expected
git show <hash of your commit>          # View details of your commit
git diff --name-status new-branch-name develop # View diff between your feature branch and local develop
git push -u origin new-branch-name      # Pushes whole branch to central repo
  • pull request
    • create a pull request
    • have someone review the change
    • then you or someone else can merge it.
  • After the pull request is merged, your local develop branch will be out of date so now update it and verify it: git status git checkout develop # switch to the develop branch git remote update # collect commits into the local repository git merge origin/develop # merge changes into the local develop branch git log --oneline --since=2.days git branch -d new-branch-name # Optionally delete your feature branch locally git push origin --delete new-branch-name # Optionally delete your feature branch remotely
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-09-13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • git使用说明
    • 配置git的环境变量
      • 复制一个Repository到客户端
        • 创建一个Repository
          • 增加一个文件
            • Git Workflow
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档