git
git配置
git config --global user.name
git config --global user.name “wait_demo”
git config --global user.email “waitMe@163.com”
git config --global core.autocrlf false
git config --list
cd myrepo2/
git
创建仓库
git init 初始化仓库
从远程仓库克隆
git status 查看文件状态
git status -s查看文件状态
git add 将未跟踪的文件加入暂存区
git reset Head 撤销已加入暂存区的文件
git commit 将暂存区的文件修改提交到本地仓库
git commit -m "init hello .txt"将暂存区的文件全部提交
git commit -m "update REAME.md"更新文件
git rm 删除文件
no .a files
*.a
but do track lib .a, even though you’re ignoring .a files above
!lib.a
#only ignore the TODO file in the current directory, not subdir/TODO
/TODO
#ignore all files in the build/ directory
build/
#ignore doc/notes.txt,but not doc/server/arch.txt
doc/*.txt
ignore all .pdf file in the doc/ directory
doc/**/*.pdf
touch .gitignore 创建.ignore文件
*.class 忽略的文件
git log 查看日志记录
远程仓库操作
git remote 查看远程仓库
git remote -v 查看远程仓库地址
git remote show origin 查看远程仓库详细信息
git remote add 添加一个新的远程git仓库,同时指定一个可以引用的简写
git remote add origin https://gitee.com/waitme488/FirstGiteeProj.git (连接远程仓库地址)
git clone 克隆远程仓库
git remote rm移除远程仓库 此命令只是从本地移除远程仓库的纪录,并不会真正影响到远程仓库
从远程仓库中抓取与拉取
git fetch 是从远程仓库获取最新版本到本地仓库,不会自动merge(合并)(git fetch origin master)通过git merge 合并
(origin/master)
git pull 是从远程仓库获取最新版本并merge到本地仓库
注意:如果当本地仓库不是从远程仓库克隆,而是本地创建的仓库,并且仓库中存在文件,此时再从远程仓库拉取文件的时候会报错(fatal:refusing to merge unrelated histories),解决方法是在git pull命令后加入参数–allow-unrelated-histories
git push [remote-name] [ branch-name] 将代码推送到远程仓库。
git pull origin master --allow-unrelated-histories配置远程仓库
git push origin master
git commit -a 将文件加到暂存区,再提交 -m 再加日志