Git使用小结

安装

在Linux系统中安装Git(以Ubuntu为例)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git

在Mac OS中安装Git

brew install git

在Windows系统中安装Git

下载Git并安装 https://git-scm.com/download/win

 

配置

git config --global user.name "your git username"

git config --global user.email "your email address for git"

 

添加文件到repository

首先切换路径到本地repository,写明要commit到本地repository的文件:

git add .

commit刚才添加到本地repository的文件并添加更新说明信息:

git commit -m "Add new files"

push所做的改变到GitHub:

git push origin your-branch

 

撤销操作 - reverting a commit

You can revert a specific commit to remove its changes from your branch. When you revert to a previous commit, the revert is also a commit. The original commit also remains in the repository's history.

这里值得注意的一点是,revert到之前的某一次commit,这本身其实仍然是一个commit,所以之前的那次commit仍然会在repository的历史中显示。

git revert <commit-hash> -m

如果是想撤销前一次的merge commit:

git revert <commit-hash> 1 -m 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值