-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadme.txt
94 lines (61 loc) · 2.44 KB
/
readme.txt
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
--------------------------------------
To create a new repository
ssh -i ~/.ssh/my-git-key [email protected] create medimag/NEWREPONAME
mkdir NEWREPONAME
cd NEWREPONAME
git init
# this just makes sure there's at least one file ...
touch README
git add README
git commit -m 'initial commit' -a
git remote add origin [email protected]:medimag/NEWREPONAME
git push origin master
---------------------------------------
To update repository
git add . # when in dir where you want to add all files or specify by name
git commit -m 'message' -a
git push origin master
-----------------------------------------
To update to a previous repository
git log path/to/file # work out which revisions to revert too
git checkout <commit> path/to/file # revert - <commit> is the descriptor tag
-----------------------------------------
Update a file to HEAD
git checkout path/to/file ~ will overite any uncommited local changes
-----------------------------------------
To clone the repository
git clone [email protected]:medimag/rosePhD.git NEWREPOFOLDERNAME
-----------------------------------------
To merge a detached head
git commit -m "commit the detached head"
git checkout -b BRANCH_NAME
git checkout master
git merge merge BRANCH_NAME # conficts result
git status # not the confilted files
git checkout BRANCH_NAME file_name1 file_name2 ...
git add file_name1 file_name2 ...
git commit -m "another commit message" -a
git push origin master
-------------------------------------------
To see changes in files
git diff HEAD optionalFileName.cxx # diff between current dir (uncommitted) and pervious commit
git diff HEAD^ # diff between current dir and two commits ago
git diff HEAD^ HEAD # diff between two commits.
----------------------------------------
Git - branch the return to origional
git branch BRANCH_NAME
git commit . -m 'message'
git
————————————————————
Split a git Repository
1. clone the repo - then filter to keep only one directory
git clone ssh://[email protected]/medimag/rosePhD.git freshrepo
git filter-branch --prune-empty --subdirectory-filter FOLDER_TO_KEEP BRANCH_TO_KEEP
2. make a new repo
ssh -i ~/.ssh/my-git-key [email protected] create medimag/NEWREPONAME
cd NEWREPONAME
git init
git push origin master
3.change the filtered repo to point to the new repo
git remote set-url origin [email protected]:medimag/NEWREPONAME
git push origin master