github创建新branch方法
code->main, 输入新branch名,create branch:
[postgres@hgcndn git_test]$ git pull
* [new branch] dev -> origin/dev
Already up-to-date.
[postgres@hgcndn git_test]$ git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/dev
remotes/origin/main
删除所有文件
[postgres@hgcndn git_test]$ git rm * -r
rm 'README.md'
[postgres@hgcndn git_test]$ git add .
[postgres@hgcndn git_test]$ git commit -m "clean all files"
[dev 3f73979] clean all files
1 file changed, 6 deletions(-)
delete mode 100644 README.md
[postgres@hgcndn git_test]$ git push origin dev
Counting objects: 3, done.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 236 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@github.com:xiangbin1997/git_test.git
5c9dcce..3f73979 dev -> dev
显示某一次commit的修改
git show [commit id]
修改没有add,放弃修改
git checkout -- .
git checkout -- [file]
删除untracked files
// -n 可以dry-run
git clean -n
Would remove src/xxx.c
// 默认clean.requireForce为true,需要-f来强制删除
git clean -f
Removing src/xxx.c
修改没有add,暂存修改
git stash save "comments"
git stash list
git stash apply [stash id]
// 包含untracked files
git stash save --include-untracked "comments"
revert某一次commit
//会生成一次新的提交,将之前commit的修改回滚掉
git revert [commitid]
删除上面几次commit
//会生成一次新的提交,将之前commit的修改回滚掉
git reset --hard [commitid]
git push -f
git pull --rebase冲突
// 通常push代码流程
git add .
git commit -m "xxx"
git pull --rebase
git push
// 在pull发生conflict后,需要解决冲突
首先编辑冲突文件,解决冲突,然后继续下面步骤
git add .
git rebase --continue
git push
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。