github简单基础用法

# github生成密匙方法
$ssh-keygen -t rsa -C "your你的邮箱"

# 初始化github,在文件夹下初始化github
$ git init

# 远程登录命令
$ git config --global user.name "your name"
$ git config --global user.email "[email protected]" 

# 添加要链接的远程仓库
$ git remote add origin [email protected]:yourName/yourRepo.git

# 克隆仓库
git clone 远程地址

# 提交远程仓库
git push origin '分支名称master'

# 更新仓库
git pull

# 提交文件
git add <filename>
git add .
这是 git 基本工作流程的第一步;使用如下命令以实际提交改动:
git commit -m "代码提交信息"
现在,你的改动已经提交到了 HEAD,但是还没到你的远端仓库
还要执行上面的 提交远程仓库 才真正完成。

# 创建github的分支
$ git branch testing

# 创建github的分支并切换到分支
$ git branch testing

# 切换到新的分支
$git checkout testing

#切换回主分支:
$git checkout master

再把新建的分支删掉:
$ git branch -d testing

除非你将分支推送到远端仓库,不然该分支就是 不为他人所见的:
$git push origin <branch>

# 合并分支
$git merge <branch>

# 在合并改动之前,你可以使用如下命令预览差异:
$git diff <source_branch> <target_branch>

# 查看历史记录
$git log

# 返回某一个版本,找到版本id,版本id用log查看
$ git reset --hard fae6966548e3ae76cfa7f38a461c438cf75ba965

猜你喜欢

转载自blog.csdn.net/keer1303242749/article/details/85253954