markdown some useful git command from my experience in case…
including:
push your local branch to remote repo
build up our work after git clone others
add and commit when in the right branch
NEVER ADD BIG FILE>100M OTHERWISE YOU WILL DIE….
- if your want to push your local branch to remote repo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38// if you update origin(remote) branch somewhere else, want to fetch the update
git fetch
// then can perform merge
// very useful to check the branch infomation for remote
// another one is
git show-ref
"""
de2138ba78c41d27f7c3ce96da6693833c35774d refs/heads/ft2mat
d56dd7b77591ef21b7a21ed7cb3e2ee91b542d22 refs/heads/xh
d56dd7b77591ef21b7a21ed7cb3e2ee91b542d22 refs/remotes/origin/HEAD
75a02a5638c7fabd77be176898ec25f24e5c7816 refs/remotes/origin/features
51553de1b544a7dde3e0e17607c3ca1038401525 refs/remotes/origin/workLocal
d56dd7b77591ef21b7a21ed7cb3e2ee91b542d22 refs/remotes/origin/xh
"""
// it means that, now we have local branch `ft2mat` but it is not in the remote repo, in this case, we are not able to `push origin/ft2mat` since the repo ft2mat does not exist
// you will meet:
# fatal: 'origin/ft2mat' does not appear to be a git repository
# fatal: Could not read from remote repository.
// then run:
$ git push --all -u
// show ref:
$ git show-ref
"""
de2138ba78c41d27f7c3ce96da6693833c35774d refs/heads/ft2mat
d56dd7b77591ef21b7a21ed7cb3e2ee91b542d22 refs/heads/xh
d56dd7b77591ef21b7a21ed7cb3e2ee91b542d22 refs/remotes/origin/HEAD
75a02a5638c7fabd77be176898ec25f24e5c7816 refs/remotes/origin/features
de2138ba78c41d27f7c3ce96da6693833c35774d refs/remotes/origin/ft2mat
51553de1b544a7dde3e0e17607c3ca1038401525 refs/remotes/origin/workLocal
d56dd7b77591ef21b7a21ed7cb3e2ee91b542d22 refs/remotes/origin/xh
"""
// now we can
$ git push origin ft2mat
!done
after clone a repo from others, we may want to build up our work on it without push our work to others’ repo1
2
3
4
5
6
7
8
9
10
11
12
13
14
15// first check the origin
$ git remote -v
origin <other repo>.....
// then change the origin into ours
$ git remote set-url origin <https://github.com/ZENGXH/caff>
// check again:
$ git remote -v
"""
origin https://github.com/ZENGXH/caff (fetch)
origin https://github.com/ZENGXH/caff (push)
"""
!done
2015/11/2
git真的是要好好学
比如说:
在不确定自己的branch的情况下不要随便add和commit。
不add和commit的话checkout new branch不会失去本地文件的。
以后要注意多和master merge要不分支越走越远,很容易就回不去了…T T