From here to GIT

Understanding Git

It is a distributed version management system written by Linus, the creator of Linux.
GitHub is a git-based code base hosting site, and it can also be regarded as a programmer's SMS. One of the main open source code release or hosting sites
git is to perform version management of files to facilitate switching between different versions. Similar files are divided into different times Back up and get one of them back when you need it, but it's more convenient to use

Common commands for Git

  1. git init initializes the warehouse
  2. git add file name: add the file to the staging area
  3. git commit -m "commit description"

Git commonly used viewing instructions

  1. git status 查看仓库当前的状态
  2. git log --pretty=oneline 查看提交的历史纪录
  3. git branch 查看当前所在的分支
  4. git branch命令会列出所有分支,当前分支前面会标一个*5. git remote 查看远程库的信息

Undo modification and version rollback

1.git checkout -- 文件名把没暂存(即没add)的干掉,或者说,丢弃工作区,
2.  git reset HEAD 文件名把暂存的状态取消,工作区内容不变,但状态变为“未暂存”。
3.  git reset --hard 黄色的就是ID ID 很长 取出6-8位就可以了
4.  git reset --hard  ID 明 也是6-8位就也可以了  

The role of branching

The role is: to facilitate collaborative development between teams, there is no conflict between codes after branching

Create and merge branches

1.  git checkout -b dev创建一个新的分支:dev,并且会切换到dev分支。
2. git checkout命令加上-b参数表示创建并切换  相当于以下两条命令:git 
3. branch dev和git checkout dev
4.  git branch dev,新建分支是新建指针,指向当前commit
5.  git checkout dev切换到dev分支
6. git checkout masterdev分支的工作完成,我们就可以切换回master分支 (此时在dev分支的修改在master上是看不到的)
7. git merge dev 这是在master分支上执行的命令,作用是:把dev分支上的工作成果合并到master分支上
8.  git branch -d dev 删除已合并的分支。删除分支就是删除指针
9. git branch -D devGit友情提醒,dev分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用git branch -D dev命令
10.git rebase master变基。在当前分支(非master)下执行该命令,则相当于把当前分支和mater分支合并,和merge操作类似,但提交历史不同,rebase操作的log更干净。具体可参考Git 分支 - 变基 

teamwork

  1. First clone the remote warehouse git clone warehouse address
  2. : After cloning, enter the warehouse folder, write the public code, and then git add, git commit -m "", git push to the warehouse just now
  3. : The administrator adds members to the "Warehouse Member Management". Note: The permissions are developer permissions
  4. : The member clones the administrator warehouse for the first time, and then creates a branch with dev and his own name locally
  5. : Members switch to the branch of their own name, then write their own code, and then git push origin their own branch name to the remote warehouse
  6. : The operation of another member is the same as the above group member, but if you need the code of the above group member, you must git pull the branch of that group member to your own branch

Git version number

  1. git tag view all
  2. git tag version number
  3. git tag -d version number delete version name
  4. git tag: the name of the version to be deleted
  5. git push origin version name push version number

Guess you like

Origin blog.csdn.net/weixin_46031162/article/details/115382442