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