1.git 常用命令

1.git命令操作
2.git 常用命令
git status 查看仓库状态

git checkout dev 切换分支到dev
git add . 添加至暂存区
git commit -m "comment" 提交 -m后跟注释
(1)创建分支命令
git branch feature1 
git checkout -b feature 建一个新分支并切换到该分支
(2)github上传
git remote add origin https://github.com/J-summit/git-command-test.git
git push -u origin master
(3)git reset/revert/checkout
git log --oneline 查看log记录
git reset --hard versionNum
(4)合并
git merge  合并指定分支到当前分支
(5)设置参数
git config --global user.name "summit"
git config --global user.email [email protected]
git 换行符
git config --global core.autocrlf  false
git config --global core.safecrlf  true
git config --global core.eol lf
(6)查看分支
git branch 查看本地所有分支
git branch -a 查看所有的分支(包括本地和远程)
git branch -r 查看远程所有分支

a 新创分支并上传至git

1.查看当前分支
git branch 
2.创建新分支并切换到其分支
git checkout -b dev
查看当前分支
git branch
3.上传新分支到git远程仓库
git push origin HEAD -u

b 更新最新代码到本地

git pull

c 上传代码

git branch
git add . 
git commit -m '注释'
git push -u

(1)新建的文件属于 工作区中,当执行git add 将文件放到暂存区,然后commit提交到本地库

1.git常用命令

git全局配置
git config --global user.name "summit"
git config --global user.email "[email protected]"
仓库初始化
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/lantian-mj/gittest.git
git push -u origin master

新增分支
git checkout -b dev(切换分支不需要-b)


(3)平时我们会使用github上传我们自己的项目,它是支持https和ssh的,https只要登入账号和密码

接下来我们演示使用ssh

ssh-keygen -t rsa -C "[email protected]"
一直回车就好

根据提示找到本地生成的秘钥
找.ssh文件下的id_rsa.pub文件打开
复制


你可能感兴趣的:(1.git 常用命令)