面经-GIT
GIT
团队维护同一份github repo,你们是工作流是怎么样的?
一般采用类似Feature Branch Workflow的流程:
1
2
3
4
5
6
7
8
9
10git clone <repo_url>
git checkout -b <new_branch_name>
# 在分支上开发
git add .
git commit -m "Commit message"
git push -u origin <new_branch_name>
# 此时会在repo上创建一个PR,团队成员对代码进行审查(code review),通过后merge到master分支
# 然后删除本地和远程的开发分支
git branch -d feature_branch_name # 删除本地分支
git push origin --delete feature_branch_name # 删除远程分支这是基本的工作流程,期间还可以加入其他步骤,例如代码静态分析(snoarQ),自动化测试,CI/CD等
git常用命令
1
2
3
4
5
6
7
8
9
10
11
12
13# always pull before push
git pull
git push
# display current status of git repository
git status
# display git commit history
git log
git log --oneline
git log --oneline --graph --decorate
# show the difference between 2 commits
git diff <commitID1> <commitID2>
# 撤销本地更改(未commit)
git reset --hard HEAD~
面经-GIT
http://example.com/2024/06/20/interview-git/