本地项目创建版本并推送到git
-
#创建README.md文件
-
-
touch README.md
-
-
#初始化git版本仓库
-
-
git init
-
-
#README.md文件添加到暂存区
-
-
git add README.md
-
-
#提交README.md
-
-
git commit -m
"first commit"
-
-
#本地仓库和远程仓库关联
-
-
git remote add origin https://gitee.com/ywl.com/springBootDemo.git
-
-
#本地仓库项目推送到远程仓库
-
-
git push -u origin master
-
-
#添加所有的文件到暂存区
-
-
git add -A
-
-
#添加并提交修改的文件
-
-
git commit -am
'commit'
-
-
#本地仓库项目推送到远程仓库
-
-
git push -u origin master
忽略已被git管理的目录或者文件
-
#切换到某个项目的git服务器
-
-
cd c:/Users/dragon/git/demo-project
-
-
#移除被git管理的target整个目录
-
-
git
rm -r --cached demo-project/demo-*/target/\*
-
-
#提交修改的git管理文件
-
-
git commit -m
'移除该文件版本管理'
-
-
#推送到远程仓库
-
-
git push origin master(你的分支)
git设置账户和密码
-
#配置使用git仓库的人员姓名
-
-
git config --global user.name
"Your Name Comes Here"
-
-
#配置使用git仓库的人员email
-
-
git config --global user.email you@yourdomain.example.com
-
-
#设置记住密码(默认15分钟)
-
-
git config --global credential.helper cache
-
-
#如果想自己设置时间,可以这样做
-
-
git config credential.helper
'cache --timeout=3600'
-
-
#长期存储密码
-
-
git config --global credential.helper store
git pull代码时冲突,本地代码还不想提交或者放弃本地修改,可以使用 stash(备份) 功能
-
一、备份并提交
-
-
#将本地代码备份
-
-
git stash
-
-
#拉取远程代码
-
-
git pull
-
-
#Git栈中读取最近一次保存的内容,由于可能存在多个stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复
-
-
git stash pop
-
-
#显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复
-
-
git stash list
-
-
#清空Git栈内容
-
-
git stash clear
-
-
二、放弃本地修改
-
-
#放弃本地修改,直接覆盖之
-
-
git reset --hard
-
-
#拉取远程代码
-
-
git pull
本地已有分支关联远程分支
-
#本地分支关联远程分支
-
-
git branch --set-upstream-to(--track) master origin/master
add 和 commit 操作合并为一条命令
-
#提交修改的文件
-
-
git commit -am
'修改文件'
-
-
#推送到远程仓库
-
-
git push origin master(你的分支)