Basic use of your own Git

What is Git?
Distributed version control system, multi-person collaborative development,
SVN
centralized version control system

The 3 components of the git warehouse
Work Directory, Stage, and History 1.
Workspace
Our usual editing work is done in the workspace
2. Temporary storage
area , where the snapshot information of the submitted file is stored
3. The history area
is the area after git commit

git workflow
1. Modify the content in the working directory
2. Take a snapshot of the modified and submitted files and save them in the temporary storage area
3. Submit the modification and permanently save the files saved in the temporary storage area in the git directory

git common commands:

git push origin develop
将本地分支推送的远程 develop 分支
 git pull 和 git feath 和 git merge
两者区别 
git pull = git featch + git merge
git featch 更加安全,可以先查看更新情况下,然后再决定是否合并
git merge : 把本地代码和已经取得的远程仓库代码合并。
git diff
比较当前文件和暂存区文件的差别
git branch -r
查看远程分支
git checkout -- file
撤销对工作区对修改
git checkout  online
切换到 online 分支
git status
查看文件修改状态,例如哪些文件在 暂存区,哪些在 历史区需要进行操作哪些

Forcibly pull remote branches & overwrite local changes:


git featch --all 
将远程修改拉取到本地
git reset --haed origin/develop
撤销本地修改,并用远程 develop 分支替换
git pull origin develop
同步远程 develop 分支代码

Git fixes bugs:

1、现将自己本地修改临时保存下
git stash save "something"
2、切换到要修改的 bug 所在的分支,并拉取 bug 代码
git checkout bug_feature
git pull
3、新建or切换到 操作修改 bug 的分支,merge bug所在分支
git checkout -b fix_bug_feature
git merge bug_feature 
4、修复 bug 完成,提交测试通过
git add
git commit -m
git push
5、切换到 bug 所在分支,并 merge 已经修复了 bug 的分支,并提交
git checkout bug_feature
git merge fix_bug_feature
git push

git reset HEAD
恢复最近一次提交过的状态
git stash
临时保存(未 add 之前)
git stash pop
恢复最近一次的临时保存

Guess you like

Origin blog.csdn.net/Misszhoudandan/article/details/109691154