git使用说明
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
非常感谢阅读!如有不足之处,请留下您的评价和问题。
请“推荐”本文!
请“推荐”本文!