github


84
84
 
1
Root /e/PlayData/git/demo1 (master)
2
$ git remote add origin https://github.com/fadewalk/test.git
3
Root /e/PlayData/git/demo1 (master)
4
$ git push -u origin master                                        # 直接将本地的push合并
5
Enumerating objects: 38, done.
6
Counting objects: 100% (38/38), done.
7
Delta compression using up to 8 threads
8
Compressing objects: 100% (29/29), done.
9
Writing objects: 100% (38/38), 3.33 KiB | 121.00 KiB/s, done.
10
Total 38 (delta 11), reused 0 (delta 0)
11
remote: Resolving deltas: 100% (11/11), done.
12
remote:
13
remote: Create a pull request for 'master' on GitHub by visiting:
14
remote: https://github.com/fadewalk/test/pull/new/master
15
remote:
16
To https://github.com/fadewalk/test.git
17
 * [new branch] master -> master
18
Branch 'master' set up to track remote branch 'master' from 'origin'.
19
20
21
Root /e/PlayData/git/demo1 (master)
22
$ git branch -r                                # 远程只有master
23
  origin/master                                # 另外的地方 无法获取dev 分支
24
25
Root /e/PlayData/git/demo1 (master)
26
$ git branch
27
  bug_001
28
  dev2
29
* master
30
31
Root /e/PlayData/git/demo1 (master)
32
$ git checkout dev2
33
Switched to branch 'dev2'
34
35
Root /e/PlayData/git/demo1 (dev2)
36
$ git branch
37
  bug_001
38
* dev2
39
  master
40
41
Root /e/PlayData/git/demo1 (dev2)                    #将本地的dev2 分支push 上去
42
$ git push -u origin dev2
43
Enumerating objects: 8, done.
44
Counting objects: 100% (8/8), done.
45
Delta compression using up to 8 threads
46
Compressing objects: 100% (5/5), done.
47
Writing objects: 100% (6/6), 619 bytes | 123.00 KiB/s, done.
48
Total 6 (delta 2), reused 0 (delta 0)
49
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
50
remote:
51
remote: Create a pull request for 'dev2' on GitHub by visiting:
52
remote: https://github.com/fadewalk/test/pull/new/dev2
53
remote:
54
To https://github.com/fadewalk/test.git
55
 * [new branch] dev2 -> dev2
56
Branch 'dev2' set up to track remote branch 'dev2' from 'origin'.
57
58
Root /e/PlayData/git/demo1 (dev2)
59
$ git branch -r                                    # 现在远端有dev,可以供别的,拉取
60
  origin/dev2
61
  origin/master
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
git pull 更新远程分支
80
(use "git pull" to merge the remote branch into yours)
81
82
83
84

113
113
 
1
Root@lewen/git/demo2
2
$ git clone https://github.com/fadewalk/test.git
3
Cloning into 'test'...
4
remote: Enumerating objects: 38, done.
5
remote: Counting objects: 100% (38/38), done.
6
remote: Compressing objects: 100% (18/18), done.
7
remote: Total 38 (delta 11), reused 38 (delta 11), pack-reused 0
8
Unpacking objects: 100% (38/38), done.
9
10
Root@lewen/git/demo2
11
$ ls
12
test/
13
14
Root@lewen/git/demo2
15
$ cd test/
16
17
Root@lewen/git/demo2/test (master)        # 发现是在master上面
18
$ git branch                              # 没有dev2 分支,主人没有上传dev分支
19
* master                                  # 需要等上传了才能看
20
21
Root@lewen/git/demo2/test (master)
22
$ cd ..
23
24
Root@lewen/git/demo2
25
$ ls
26
test/
27
28
Root@lewen/git/demo2            # 来早了,先删掉,等主人上传dev了,再来。
29
$ rm -fr test/
30
31
Root@lewen/git/demo2
32
$ git clone https://github.com/fadewalk/test.git        # 重新克隆,应该有了吧
33
Cloning into 'test'...
34
remote: Enumerating objects: 44, done.
35
remote: Counting objects: 100% (44/44), done.
36
remote: Compressing objects: 100% (21/21), done.
37
remote: Total 44 (delta 13), reused 44 (delta 13), pack-reused 0
38
Unpacking objects: 100% (44/44), done.
39
40
Root@lewen/git/demo2
41
$ ls
42
test/
43
44
Root@lewen/git/demo2
45
$ cd test/
46
47
Root@lewen/git/demo2/test (master)
48
$ ls
49
index.html main.js readme.md style.css
50
51
Root@lewen/git/demo2/test (master)
52
$ git branch -r                            # 查看远程分支都有哪些
53
  origin/HEAD -> origin/master             # 发现有自己想要的dev 分支了
54
  origin/dev2
55
  origin/master
56
57
Root@lewen/git/demo2/test (master)
58
$ git branch -a                            # 查看所有分支。本地只有一个master
59
* master
60
  remotes/origin/HEAD -> origin/master
61
  remotes/origin/dev2
62
  remotes/origin/master
63
64
65
Root@lewen/git/demo2/test (master)
66
$ cat readme.md
67
bug fix=>master
68
Root@lewen/git/demo2/test (master)            # 那就本地就根据(跟踪)远程origin的dev创建dev 
69
$ git checkout -b dev2 origin/dev2            
70
Switched to a new branch 'dev2'
71
Branch 'dev2' set up to track remote branch 'dev2' from 'origin'.
72
73
74
75
Root@lewen/git/demo2/test (dev2)
76
$ git branch -a                               # 好了现在本地也有dev分支了,可以修改开发dev了
77
* dev2
78
  master
79
  remotes/origin/HEAD -> origin/master
80
  remotes/origin/dev2
81
  remotes/origin/master
82
83
Root@lewen/git/demo2/test (dev2)
84
$ cat readme.md
85
branch dev===>master
86
87
88
89
B 提交的
90
91
在A查看
92
93
Administrator@lewenbook MINGW64 /e/PlayData/git/demo1 ((57253a1...))
94
$ git status
95
HEAD detached at origin/dev2
96
nothing to commit, working tree clean
97
98
Administrator@lewenbook MINGW64 /e/PlayData/git/demo1 ((57253a1...))
99
$ cat readme.md
100
hello from stuB
101
102
Administrator@lewenbook MINGW64 /e/PlayData/git/demo1 ((57253a1...))
103
$ git checkout dev2
104
Previous HEAD position was 57253a1 modify readme.md at stuB on dev2
105
Switched to branch 'dev2'
106
Your branch and 'origin/dev2' have diverged,
107
and have 3 and 1 different commits each, respectively.
108
  (use "git pull" to merge the remote branch into yours)
109
110
Administrator@lewenbook MINGW64 /e/PlayData/git/demo1 (dev2)
111
$ cat readme.md
112
this demo1A dev
113


git pull 更新远程的分支并合并到本地    。少用

git fetch
    merge

61
61
 
1
#  git fetch 同步远程更新
2
#  看是不是自己想要的跟新,然后再merge
3
4
5
$ git fetch origin dev2
6
remote: Enumerating objects: 5, done.
7
remote: Counting objects: 100% (5/5), done.
8
remote: Compressing objects: 100% (1/1), done.
9
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
10
Unpacking objects: 100% (3/3), done.
11
From https://github.com/fadewalk/test
12
 * branch            dev2       -> FETCH_HEAD
13
   0b93d1e..cc7b6f1  dev2       -> origin/dev2
14
15
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test (dev2)
16
$ git checkout  remotes/origin/dev2
17
Note: checking out 'remotes/origin/dev2'.
18
19
You are in 'detached HEAD' state. You can look around, make experimental
20
changes and commit them, and you can discard any commits you make in this
21
state without impacting any branches by performing another checkout.
22
23
If you want to create a new branch to retain commits you create, you may
24
do so (now or later) by using -b with the checkout command again. Example:
25
26
  git checkout -b <new-branch-name>
27
28
HEAD is now at cc7b6f1 modify readme.md to A
29
30
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test ((cc7b6f1...))
31
$ git status
32
HEAD detached at origin/dev2
33
nothing to commit, working tree clean
34
35
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test ((cc7b6f1...))
36
$ cat readme.md
37
from A
38
39
40
41
42
43
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test ((cc7b6f1...))
44
$ git checkout  dev2
45
Previous HEAD position was cc7b6f1 modify readme.md to A
46
Switched to branch 'dev2'
47
48
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test (dev2)
49
$ cat readme.md
50
A
51
52
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test (dev2)
53
$ git merge origin/dev2 --no-ff
54
Merge made by the 'recursive' strategy.
55
 readme.md | 2 +-
56
 1 file changed, 1 insertion(+), 1 deletion(-)
57
58
Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test (dev2)
59
$ cat readme.md
60
from A
61





fork
pull requst



别名

git config.conf  


Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test (dev2)
$ git config --global alias.ci commit

Administrator@lewenbook MINGW64 /e/PlayData/git/demo2/test (dev2)
$ cat ~/.gitconfig
[user]
        email = fadewalk@163.com
        name = lewen
[alias]
        ci = commit
  








搭建git服务器






posted @ 2020-06-08 21:13  Fadewalk  阅读(197)  评论(0编辑  收藏  举报