您当前的位置:首页 > 计算机 > 软件应用 > 开发工具(IDE)

实用的 Git 命令分享

时间:12-14来源:作者:点击数:

commit forgotten file

$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend

revert comit and add to another branch

Imagine you commit file on wrong branch(staging) but not push yet

$ git log --oneline; // find the commit hash is LAST_COMMIT_HASH
$ git checkout dev
$ git cherry branch LAST_COMMIT_HASH
$ git push
$ git checkout staging
$ git revert LAST_COMMIT_HASH
$ git push // the LAST_COMMIT_HASH would be replaced by a newer hash

delete local and remote branch

$ git branch -d staging-backup // local
Deleted branch staging-backup (was c1aabf0).

$ git push --delete origin import // remote
To code.aliyun.com:tsp-fe/tsp-web-fe.git
 - [deleted]         import
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐