git

[root@kunpeng82 mininet]# git branch -vv
* master bfc42f6 [origin/master] Merge pull request #921 from timgates42/bugfix/typo_updates
[root@kunpeng82 mininet]# git config --lis
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/mininet/mininet
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
[root@kunpeng82 mininet]#

 

$ cd mininet
$ git tag
1.0.0
2.0.0
2.1.0
2.1.0p1
2.1.0p2
2.2.0b0
2.2.0b1
2.2.0b2
2.2.0b3
cs244-spring-2012-final
Above, we see the latest available beta release is 2.2.0b3. So, we switch to that branch on our virtual machine.

$ git checkout -b 2.2.0b3
Switched to a new branch '2.2.0b3'

 

root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git init
Reinitialized existing Git repository in /data1/root/ryu/sdn-ip/Ryu-SDN-IP/.git/
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# rm -rf .git
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git init
Initialized empty Git repository in /data1/root/ryu/sdn-ip/Ryu-SDN-IP/.git/
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git commit -m "first commit"



root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git remote add origin https://github.com/magnate3/Ryu-SDN-IP.git
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git pull --rebase origin master
fatal: Updating an unborn branch with changes added to the index.
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/magnate3/Ryu-SDN-IP.git'
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git branch 
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git checkout -b dev
Switched to a new branch 'dev'
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git branch
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/magnate3/Ryu-SDN-IP.git'
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git add .
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git commit -m"xxx"
[dev (root-commit) 8cc3cee] xxx
 Committer: root <root@ubuntu.ubuntu>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 18 files changed, 1137 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 LICENSE
 create mode 100644 README.md
 create mode 100644 VERSION
 create mode 100755 bin/sdnip-mgr
 create mode 100644 config.json.bak
 create mode 100644 config.sample.json
 create mode 100644 requirements.txt
 create mode 100644 sdnip/__init__.py
 create mode 100644 sdnip/arp_proxy.py
 create mode 100644 sdnip/conf_mgr.py
 create mode 100644 sdnip/fwd.py
 create mode 100644 sdnip/fwd_bgp.py
 create mode 100644 sdnip/hop_db.py
 create mode 100644 sdnip/sdn_ip.py
 create mode 100644 setup.cfg
 create mode 100644 setup.py
 create mode 100644 static_arp_table.sample.json
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git pull origin dev
fatal: Couldn't find remote ref dev
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git push origin dev
Username for 'https://github.com': magnate3
Password for 'https://magnate3@github.com': 
Counting objects: 21, done.
Delta compression using up to 64 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (21/21), 11.21 KiB | 2.80 MiB/s, done.
Total 21 (delta 0), reused 0 (delta 0)
To https://github.com/magnate3/Ryu-SDN-IP.git
 * [new branch]      dev -> dev
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP#

 

root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git add sdn-ip-topology
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git push origin dev
Username for 'https://github.com': magnate3
Password for 'https://magnate3@github.com': 
Everything up-to-date
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git diff
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git status
On branch dev
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   README.md
        new file:   sdn-ip-topology/configs/quagga-sdn.conf
        new file:   sdn-ip-topology/configs/quagga1.conf
        new file:   sdn-ip-topology/configs/quagga2.conf
        new file:   sdn-ip-topology/configs/quagga3.conf
        new file:   sdn-ip-topology/configs/quagga4.conf
        new file:   sdn-ip-topology/configs/zebra.conf
        new file:   sdn-ip-topology/quagga-sdn.conf
        new file:   sdn-ip-topology/quagga-test1.py
        new file:   sdn-ip-topology/quagga1.conf
        new file:   sdn-ip-topology/quagga2.conf
        new file:   sdn-ip-topology/quagga3.conf
        new file:   sdn-ip-topology/quagga4.conf
        new file:   sdn-ip-topology/zebra.conf

root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP#

之所以引起Everything up-to-date这个信息的原因有:

1)没有git add;
2)git add 了,但忘了git commit -m “提交信息”

 

root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git push origin dev
Username for 'https://github.com': magnate3
Password for 'https://magnate3@github.com': 
Everything up-to-date
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git add README.md sdn-ip-topology
root@ubuntu:/data1/root/ryu/sdn-ip/Ryu-SDN-IP# git commit -m"add step of creating topo"

 

root@gobgp:~/work/vpp# git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/map-fib
  remotes/origin/master
  remotes/origin/stable/1606
  remotes/origin/stable/1609
  remotes/origin/stable/1701
  remotes/origin/stable/1704
  remotes/origin/stable/1707
  remotes/origin/stable/1710
  remotes/origin/stable/1801
  remotes/origin/stable/1804
  remotes/origin/stable/1807
  remotes/origin/stable/1810
  remotes/origin/stable/1901
  remotes/origin/stable/1904
  remotes/origin/stable/1908
  remotes/origin/stable/2001
  remotes/origin/stable/2005
  remotes/origin/stable/test


root@gobgp:~/work/vpp# git checkout   stable/1908
Branch 'stable/1908' set up to track remote branch 'stable/1908' from 'origin'.
Switched to a new branch 'stable/1908'
root@gobgp:~/work/vpp# 

 

 

github添加项目

 

echo "# qemu-aarch64" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/xxx/qemu-aarch64.git
git push -u origin main

 

 

 

 

 

 

 

 

 

 

 

 

 

github更新项目

 

 

 

 

 

 

  git init
   git add -A
  git commit -m"add dpdk test demo"
 git remote add origin  https://github.com/magnate3/dpdk.git
   git push -u origin master

 

1 、 对需要删除的文件、文件夹进行如下操作:

git rm test.txt (删除文件)

git rm -r test (删除文件夹)

 提交修改

git commit -m "Delete some files."

 将修改提交到远程仓库的xxx分支:

git push origin xxx

 

2、 删除远程仓库 但不删本地资源

  git rm -r --cached xxx.iml  //-r 是递归的意思 当最后面是文件夹的时候有用

  (git add xxx.iml)      //若.gitignore文件中已经忽略了xxx.iml则可以不用执行此句

  git commit -m "ignore xxx.xml"

  git push

 

 

 

 

1、 本地执行了rm操作而不是git rm,怎么把远程rm

[root@localhost demo]# git rm -r --cached  dpdk-pingpong/build
fatal: pathspec 'dpdk-pingpong/build' did not match any files
[root@localhost demo]# cd dpdk-pingpong/
[root@localhost dpdk-pingpong]# ls
build  help.h  main.c  main.c.bak  main.c.bak2  Makefile  README.md
[root@localhost dpdk-pingpong]# git rm build -r
fatal: pathspec 'dpdk-pingpong/build' did not match any files
[root@localhost dpdk-pingpong]# git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       build/
nothing added to commit but untracked files present (use "git add" to track)
[root@localhost dpdk-pingpong]# 

 

 

 

 

 

 

 

 

 

error: pathspec 'add show_dup fun to show all segs of udp' did not match any file(s) known to git.
[root@localhost demo]# git add ip_reassembly --all
[root@localhost demo]# git commit 'add show_dup fun to show all segs of udp'
error: pathspec 'add show_dup fun to show all segs of udp' did not match any file(s) known to git.
[root@localhost demo]# git branch -a
  dev
* master
  remotes/origin/master

没有加-m

 

 

error: 'commit' is not possible because you have unmerged files.
[root@localhost demo]# git commit -m "add show_dup fun to show all segs of udp"
U       ip_reassembly/Makefile
U       ip_reassembly/main.c
U       ip_reassembly/readme
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
[root@localhost demo]# git add ip_reassembly --all
[root@localhost demo]# git commit -m "add show_dup fun to show all segs of udp"
[master de02ba6] add show_dup fun to show all segs of udp
 Committer: root <root@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

[root@localhost demo]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': magnate3
Password for 'https://magnate3@github.com': 
Counting objects: 49, done.
Delta compression using up to 128 threads.
Compressing objects: 100% (36/36), done.
Writing objects: 100% (36/36), 16.12 KiB | 0 bytes/s, done.
Total 36 (delta 18), reused 0 (delta 0)
remote: Resolving deltas: 100% (18/18), completed with 9 local objects.
To https://github.com/magnate3/dpdk.git
   51b0f43..de02ba6  master -> master

 

 

git撤销

 

查看commit

git log -1
commit b0925803c3c34223d717514da959a07a12ab0e27 (HEAD -> master, origin/master, origin/HEAD)
Author: Diana Popa <dpopa@amazon.com>
Date:   Tue Dec 22 10:44:16 2020 +0200

    CI: add git commit message linter
    
    Fixes #1231
    
    Signed-off-by: Diana Popa <dpopa@amazon.com>

 

 

同步远程分支

  • git fetch 将本地分支与远程保持同步
  • git checkout -b 本地分支名x origin/远程分支名x 拉取远程分支并同时创建对应的本地分支

 

root@ubuntu:~/myfirecracker/firecracker# git fetch --all
Fetching origin
remote: Enumerating objects: 95, done.
remote: Counting objects: 100% (95/95), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 98 (delta 60), reused 76 (delta 46), pack-reused 3
Unpacking objects: 100% (98/98), done.
From https://github.com/firecracker-microvm/firecracker
364cf32..16af75a master -> origin/master

root@ubuntu:/myfirecracker/firecracker # git reset --hard origin/master

 

 

root@cloud:/gvisor# git fetch --all
Fetching origin
remote: Enumerating objects: 431, done.
remote: Counting objects: 100% (431/431), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 494 (delta 396), reused 417 (delta 386), pack-reused 63
Receiving objects: 100% (494/494), 86.63 KiB | 34.00 KiB/s, done.
Resolving deltas: 100% (397/397), completed with 266 local objects.
From https://github.com/google/gvisor
   a20da7082..e74aa25e2  master           -> origin/master
   1ea6658d2..43ca8a82c  go               -> origin/go
 + 2d5ef5235...bf35d7304 test/cl344879562 -> origin/test/cl344879562  (forced update)
 + 39e12b533...fee5d2cdc test/cl347771969 -> origin/test/cl347771969  (forced update)
 + b0d2ba55c...997c55550 test/cl350844518 -> origin/test/cl350844518  (forced update)
 + 7573892aa...0b255067a test/cl350862614 -> origin/test/cl350862614  (forced update)
 + 08ebd4d99...4950c8eef test/cl351261565 -> origin/test/cl351261565  (forced update)
 * [new branch]          test/cl351393647 -> origin/test/cl351393647
 * [new branch]          test/cl351424216 -> origin/test/cl351424216
 * [new branch]          test/cl351428246 -> origin/test/cl351428246
 * [new branch]          test/cl351436580 -> origin/test/cl351436580
 * [new branch]          test/cl351468163 -> origin/test/cl351468163
 * [new branch]          test/cl351476479 -> origin/test/cl351476479
 * [new branch]          test/cl351508241 -> origin/test/cl351508241
root@cloud:/gvisor# bazel clean --expunge
Starting local Bazel server and connecting to it...
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
root@cloud:/gvisor# bazel build //runsc
Starting local Bazel server and connecting to it...

 

 git tag

root@ubuntu:~/myfirecracker/firecracker# git tag -l
foobar
v0.1.0
v0.1.1
v0.10.0
v0.10.1
v0.11.0
v0.12.0
v0.13.0
v0.14.0
v0.15.0
v0.15.1
v0.15.2

 

git reset --hard <HEAD/commitId/branch/tag>

git reset --hard v0.24.0
HEAD is now at 74a5731f Update cargo lock.

 

git rm 删除 以及清空暂存区

一.使用linux命令rm删除:

在当前工作区有文件readme.txt,并被git跟踪,且有提交历史。运行如下命令:

rm readme.txt

删除后状态截图

分析如下:

(1)readme.txt文件的状态是被删除。

(2)此时工作区中的文件已经被删除,

(3)Changes not staged for commit 表明删除文件和新增文件对Git来说都是一种改变,并没有将此改变提交到暂存区。如果要切实在commit提交中也要删除此文件,那么就要首先将此种改变提交暂存区:

git add readme.txt

然后完成此次提交:

git commit -m "delete readme"
 

二.使用git rm命令删除:

通过纯粹的linux命令删除一个文件需要三个步骤:

(1)rm 删除文件。

(2)将此种改变提交暂存区。

(3)最后进行commit提交。

使用git rm命令可以节省一步,代码如下:

git rm readme.txt

查看一下此时状态:

a:3:{s:3:\"pic\";s:43:\"portal/201807/26/010036vsxacxc0afsz10c0.png\";s:5:\"thumb\";s:0:\"\";s:6:\"remote\";N;}

分析如下:

(1)readme.txt处于deleted状态。

(2)工作区中的文件已经被删除。

(3)Changes to be committed表明此删除改变已经提交到暂存区,如果要切实在commit提交中也要删除此文件,就可以省略git add命令,直接commit提交即可。

git commit -m "delete readme"
 

三.使用--cached参数:

前面的rm和git rm都会将工作区的文件删除,如果仅仅想让文件脱离Git的跟踪,可以后面加--cached。

这样工作区的文件不会删除,仅删除暂存区中对应的文件。

代码如下:

git rm readme.txt --cached

查看一下状态:

a:3:{s:3:\"pic\";s:43:\"portal/201807/26/010150og1nn178i7qo9e9h.png\";s:5:\"thumb\";s:0:\"\";s:6:\"remote\";N;}

readme.txt处于未跟踪状态,也就是从暂存区删除。

特别说明:处于未跟踪状态只是没有存在于暂存区,历史提交记录中的记录依然存在。

 

附:清空暂存区

所谓的暂存区仅仅是.git目录下的一个index文件罢了,这也是为了什么被称为index(索引)

a:3:{s:3:\"pic\";s:43:\"portal/201807/18/001723t4dck4mdo1etp1sx.png\";s:5:\"thumb\";s:0:\"\";s:6:\"remote\";N;}

当删除暂存区内容的时候,其实就是删除index文件中的内容,.git/objects目录中的内容不会被删除。

指令:rm .git/index 直接删除该文件夹即可

 

 

this exceeds GitHub's file size limit of 100.00 MB

git push -u origin main
Username for 'https://github.com': magnate3
Password for 'https://magnate3@github.com': 
Counting objects: 2017, done.
Delta compression using up to 64 threads.
Compressing objects: 100% (1859/1859), done.
Writing objects: 100% (2017/2017), 48.79 MiB | 2.06 MiB/s, done.
Total 2017 (delta 301), reused 0 (delta 0)
remote: Resolving deltas: 100% (301/301), done.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 138e28683f9fb42af1623f1f014313888ba66590da602ad6ba2a094882cc17a9
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File .ci/cl@10.10.16.48 is 176.00 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/magnate3/kata_anbox_tests.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/magnate3/kata_anbox_tests.git'

 

rm .ci/cl@10.10.16.48

 

   git filter-branch --force --index-filter "git rm --cached --ignore-unmatch .ci/cl@10.10.16.48"  --prune-empty --tag-name-filter cat -- --all
   git commit --amend 
ctrl+ x,输入y

 

 git push -u origin main

 

posted on 2020-07-13 14:09  tycoon3  阅读(282)  评论(0编辑  收藏  举报

导航