Git使用操作指南
1.Git常用命令集锦
git init #add a new git repository in current directory
git config user.name # set the username for current project
git config user.email # set the email for the current project
git config --global user.name # set the global username
git config --global user.email # set the global email
git status # check the status
git branch # check all the branch of the local repository
git add file_name # add a new file into the temporary storage
git add . # add all files into the temporary storage
git rm --cached file_name # recall the file form the temporary storage
git commit file_name # commit the content of temporary storage on the local respository
git commit -m “descriptions” file_name # commit the content of temporary storage on the local respository with descriptions
git log # check all commit log
git log --pretty=oneline # check all commit log with information in oneline
git log --oneline # check all commit log with part of information in oneline
git rm file_name # remove file
git diff # check the content of updating
git branch -v # check all branches of current projecct
git branch branch_name # create a new branch in local repository
git checkout branch_name # change into the new branch
git checkout master # change back to the master
git merge branch_name # merge current branch into master
git push repository_name branch_name # git push origin master: push local pository to the branch of remote respository
git clone remote_repository_address # clone project from remote respository address
git remote -v # check the alias of the remote repository
git remote add alias # add a new alias for the remote repository
git merge --abort # uncall the merge
git reflog 显示所有版本的提交历史(会有索引信息)
git reset --hard 索引值 根据索引值切换版本
git reset --hard HEAD^ 指令中包含几个^符号则代表回退几个版本。
git reset --hard HEAD~2 ~后的数字代表几个版本
git reset --soft 索引值 根据索引值切换版本(HEAD指针指向最新版本,但文件并没有恢复到最新版本)
git reset --mixed 索引值 根据索引值切换版本(mixed参数会改变版本区的指针并重置索引)
2.Git常用操作
2.1Git克隆新项目
## clone 远程仓库到本地
git clone https://github.com/naveenanimation20/PageObjectModel.git
## 指定分支dev 分支 clone项目
git clone -b dev https://github.com/naveenanimation20/PageObjectModel.git