1. Zibaojiamen
git config --global user.name SLIGHTLEE
git config --global user.email [email protected]
查看配置
git config --list
2. Create Repository
进入到 E盘目录 cd e:/
创建文件夹 mkdir shopMatnager
创建仓库 git init
2.1 2.1.1 Add File to create a file hello.txt
查看状态 git status
提交文件到暂存区 git add hello.txt 或者 当前目录下的所有文件 git add .
提交文件到版本库 git commit -m "init" -m 注释
## 将工作区文件 直接添加到版本库
git commit -am "直接提交"
-------------------------
workspace repository staging area
------------------ -------
2.1.2 release revoked describe
submit and file a staging area on the revocation resubmitted
revised document add to the staging area and then use
git commit --amend
can modify the version described in
2.1.3 revoke workspace modify
撤销单个文件提交 git checkout -- index.txt
撤销多个文件提交 git checkout -- .
2.1.4 revoke modify staging area
git reset HEAD index.txt
2.2 Delete Files
2.2.1
If you delete a file read.txt
use git git rm read.txt delete
view the status of green
git commit -m "delete files"
if it is to manually remove the need to add a step in the operation git add
2.3 to push to a remote repository
2.3. 1
The first:
official steps:
git remote add origin https://gitee.com/leagle/hand_in_hand.git
git push -u origin master
git remote add origin https://gitee.com/leagle/y-mall.git
git pull origin master
Shorthand remote address add a remote database alias origin
[when the first push is no need to use later -u]
The second:
git the Push https://gitee.com/leagle/hand_in_hand.git Master
2.4 pulled from a remote repository take projects
(new user operations)
2.4.1 disk operation first enter a drive letter
cd d:/
git clone https://gitee.com/leagle/hand_in_hand.git
2.4.2 After modifying the file to add files to the workspace commit staging area
push to push https://gitee.com/leagle/hand_in_hand.git Master remote repository git
(before the user operation)
2.4.3 update from a remote disk into the d warehouse project pull
git pull https://gitee.com/leagle/hand_in_hand.git Master
2.5 change log
2.5.1
View project log git log
to see the catalog log git log.
感觉log乱 可以使用 git log --pretty=oneline 或则 git log --oneline
As follows:
e378ce033a1469efef6c40c0599f29d0a4f33768 (the HEAD -> Master) update Remember.md
2f7a71801dc08a1dba933960a84c9fc8089493db (Origin / Master) Edit Content
9f79b1ecbfbad70e5923ed042cc7b75d96bf447a the Delete file
ce63053ff7246c4cb5f86369c9d095966116a725 submit hello.txt
the first time to submit 8e1b8380500a438040527ad0b7581e2204a8acec
2.6 Version Switch
查看版本变化 git reflog
e378ce0 (the HEAD -> Master) the HEAD @ {0}: Master pull https://gitee.com/leagle/hand_in_hand.git: Fast-Forward
2f7a718 (Origin / Master) the HEAD. 1} {@: the commit: Edit Content
9f79b1e the HEAD @ {2}: commit: delete file
ce63053 hEAD @ {3}: commit : Submit hello.txt
8e1b838 the hEAD. 4} {@: the commit (Initial): Submit the first time
when the head 1 pointing to the current version git reset --hard hEAD ^
version cut the RESET --hard 2f7a718 git
2.7 branch management
2.7.1 switching branch
查看分支 git branch
创建分支 git branch wechat
切换分支 git checkout wechat
修改分支名字 git branch -m wechat cc
创建分支并切换分支 git branch -b dev
1. In the commit wechat branching operation the Add
2.7.2 merging branches
1. wechat incorporated into the master
合并分支(切换到master操作) git merge wechat
2. Different branches of the same file are modified
as follows:
lalalal wechat
<<<<<<< HEAD
modified master
=======
modified WeChat
>>>>>>> WeChat
the conflicting portions Notes removed
lalalal wechat
master modify
modify wechat
then add commit
the use of strong cover alternative content in the git repository with your local code git push -f
2.7.3 Delete branch
git branch -d wechat
2.8 remote repository
2.8.1
# to view a remote repository aliases
查看远程仓库 git remote
查看远程仓库地址 git remote -v
# Delete remote repository aliases (such as an alias for the origin)
git remote remove origin
2.9
2.9.1 Key to create SSH
SSH-keygen -t rsa -C "[email protected]"
way to enter. . .
.id_rsa public private .id_rsa.pub
local public with the private key with remote