创建账户:
git config --global user.email "you@example.com" 配置邮箱
git config --global user.name "Your Name" 配置用户名
删除全局配置,重新修改:
git config --global --unset user.name
git config --global --unset user.email
or
git config --local --user.email "you@example.com"
git config --local --user.name "Your Name"
重新输入账号密码(错误fatal: Authentication failed for):
git config --system --unset credential.helper
设置记住密码:
git config --global credential.helper store
创建文件
touch 文件名
初始化本地仓库
git init
关联远程git仓库
git remote add origin https://gitlab.com/xxx.git
克隆仓库
git clone https://gitlab.com/xxx.git
拉取指定分支
git clone -b 分支名 https://gitlab.com/xxx.git
提交文件到本地暂存区
添加单个
git add 文件名
添加全部
git add.
提交文件到本地版本库
git commit
git commit -m '描述文字'
git commit -a -m ‘描述文字
提交到远程仓库
git push -u origin master
拉取远程仓库代码
git pull -u origin master
将远程主机的最新内容拉到本地
git fetch origin master
删除git区域中记录的文件,并且不保留在工作目录中
git rm 文件名
删除Git仓库中的,保留工作目录中的文件
git rm --cache 文件名
强制删除文件
git rm -f 文件名
查看工作目录及暂存区内容
git status
查看提交记录
git log
查看详细提交信息
git log -p FETCH_HEAD
查看n条提交信息
git log -n
查看配置信息
git config --list
查看远程分支
git branch -a
切换当前分支
git checkout 分支名
合并分支
git merge 分支名
退到/进到 指定commit的代码
git reset --hard commit_id