查看当前分支
git branch #
添加
git add .
查看提交状态
git status
提交
git commit ->ESA :wq \git commit -m""
同步
git push 提交
合并分支
创建分支
git checkout -b "新的分支名称"
git add .
git status
git commit
git push
git checkout master
git merge 新的分支名称
删除
rm 文件名称 反编译''
git add .
git status
git commit
git push
删除远程仓库
git branch #查看当前所在分支
git branch -d dev_lizhen #删除本地名为dev_lizhen的分支
git push origin --delete dev_lizhen #删除远程仓库中名为dev_lizhen的分支
以下是提交记录:
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git checkout -b a
Switched to a new branch 'a'
Your branch is based on 'origin/a', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (a)
$ git add .
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (a)
$ git status
On branch a
Your branch is based on 'origin/a', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: ass.txt
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (a)
$ git commit
[a caf1a3b] 提交到分支
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 ass.txt
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (a)
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 272 bytes | 272.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.2]
remote: Create a pull request for 'a' on Gitee by visiting:
remote: https://gitee.com/yufeilong/git-test/pull/new/yufeilong:a...yufeilong:master
To https://gitee.com/yufeilong/git-test.git
* [new branch] a -> a
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (a)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git merge a
Updating 9cb32b8..caf1a3b
Fast-forward
ass.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 ass.txt
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/yufeilong/git-test.git
9cb32b8..caf1a3b master -> master
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git branch -d a
Deleted branch a (was caf1a3b).
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push origin --delete a
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/yufeilong/git-test.git
- [deleted] a
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git branch #
* master
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ rm AUTHORS
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
deleted: AUTHORS
no changes added to commit
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push
Everything up-to-date
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ rm 新建 文本文档.txt
rm: cannot remove '新建': No such file or directory
rm: cannot remove '文本文档.txt': No such file or directory
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ rm '新建 文本文档.txt'
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
deleted: AUTHORS
deleted: "\346\226\260\345\273\272 \346\226\207\346\234\254\346\226\207\346\241\243.txt"
no changes added to commit
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push
Everything up-to-date
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ rm ass.txt
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
deleted: AUTHORS
deleted: ass.txt
deleted: "\346\226\260\345\273\272 \346\226\207\346\234\254\346\226\207\346\241\243.txt"
no changes added to commit
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
deleted: AUTHORS
deleted: ass.txt
deleted: "\346\226\260\345\273\272 \346\226\207\346\234\254\346\226\207\346\241\243.txt"
no changes added to commit
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push
Everything up-to-date
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
deleted: AUTHORS
deleted: ass.txt
deleted: "\346\226\260\345\273\272 \346\226\207\346\234\254\346\226\207\346\241\243.txt"
no changes added to commit
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git add .
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: AUTHORS
deleted: ass.txt
deleted: "\346\226\260\345\273\272 \346\226\207\346\234\254\346\226\207\346\241\243.txt"
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
Aborting commit due to empty commit message.
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push
Everything up-to-date
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git commit
[master 1bd1c07] 删除数据
3 files changed, 79 deletions(-)
delete mode 100644 AUTHORS
delete mode 100644 ass.txt
delete mode 100644 "\346\226\260\345\273\272 \346\226\207\346\234\254\346\226\207\346\241\243.txt"
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 234 bytes | 234.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/yufeilong/git-test.git
caf1a3b..1bd1c07 master -> master
Dell@DESKTOP-0PFJDQU MINGW64 /d/gitTest/git-test (master)
生产补丁
提交代码
1.查看状态 git status
image.png
2.查看代码修改内容git diff <可以指定文件>
image.png
3.添加修改文件 git add .
image.png
4.提交代码 git commit /git commit --m "修改内容"
image.png
4.1 git commit >输入修改内容>按 i,并输入":wq",保持退出
4.2 git commit --m 无需上面操作
5.提交代码 git push origin <分支名称>
image.png
6.生产补丁
6.1 git log ,通过log ,我们就可以生成补丁,例如:第七次提交,只要执行git format-patch 第六次的提交commit-id即可,如果执行第一次提交的commit-id,那就会生产所有提交的patch
image.png
image.png
image.png
- 这样我们就可以生产补丁了,
至于打补丁,执行如下
7.1 git am 补丁名称
修改提交内容
git commit --amend
or
git apply 补丁名称
git add .
git commit /git commit -m ''
git push origin
网友评论