git init 初始化git仓库

配置用户名:git config --global usre.name 'wangzhanhan-bit'
配置用户邮箱:git config --global user.email '2593983614@qq.com'

把文件放进仓库
新建文件admin.txt,输入内容


git add 文件目录/文件名 或者使用 git add ./意思是把当前路径下的所有文件放到存储区
git commit -m "说明 或者使用git commit --all -m"说明“把所有文件放到仓库中。

git status察看文件状态命令
查看历史提交日志git log(git log --oneline 查看简介版日志)

git reset --hard Head~0后退到上一次的代码(git reset --hard 版本号)


git reflog 可以看到每一次切换版本的记录


创建分支 git branch 分支名(例:git branch dev创建dev分支)
git branch 查看当前有哪些分支

切换分支 git checkout 要切换的分支名(例:git checkout dev 切换到dev分支)

合并分支git merge dev 把当前分支与指定的dev分支结合

git pull https://github.com/user.name/text1.git master上传
git push https://github.com/user.name/text1.git master下载
在pull和push中先pull在push

git remote add origin https://github.com/user.name/text1.git master
git push origin master
前一句使用后相当于给此项目一个origin代替地址方便后续操作
git push origin -u master
git push
前一句使用后相当于给了一个关联使得后续操作变得简单省略master。
网友评论