-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgit.txt
More file actions
149 lines (90 loc) · 3.6 KB
/
git.txt
File metadata and controls
149 lines (90 loc) · 3.6 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Notes on git
Initial stuff
git config --global user.name "Your Actual Name"
git config --global user.email "youremail@somewhere.com"
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global core.editor emacs
git config --global core.excludesfile ~/.gitignore_global
Clone repository
git clone git@github.com:kbroman/qtl
git clone git://github.com/kbroman/qtl
git clone https://github.com/kbroman/qtl
The basics
git pull
git commit -a
git push
Also
git status
git diff
git diff 1.16-6 R/est.map.R
git diff 1.16-6 R/est.map.R | gitx
git diff --name-status main..[some branch]
Tagging
git tag -a -m "tagging version 1.11-7" 1.11-7
git push --tags
git tag -d 1.11-7 [deleting a tag]
git push origin :refs/tags/1.11-7 [remove tag from origin that I'd removed locally]
git push --delete origin 1.11-7 [another way to remove tag from origin]
git tag -a tag_label 9fceb02 -m "Message here" [tag an older commit]
Branching and merging
git branch [to see what branches there are]
git branch blah [to create the 'blah' branch]
git checkout blah [to switch to the 'blah' branch
git checkout main; git merge blah [merge blah into main]
Going back
git reset --hard [throw all changes away]
git checkout myfile.txt [throw away changes to myfile.txt]
git commit --amend [revise the last commit message]
github stuff
git checkout MQM
git pull git@github.com:myfriend/rqtl-mqm.git
git pull git@github.com:myfriend/rqtl-mqm.git/main
git pull myfriend main
git pull myfriend myfriend
git push --set-upstream origin <branch>
git push origin <branch>
git push origin --delete <branch>
git remote prune origin --dry-run # Check for defunct remote branches
git remote prune origin # Delete local copies of defunct remote branches
To remove a local copy of a remote branch (say it shows up in
"branch -a" as "remotes/origin/pptx
git branch -r -d origin/pptx
github remotes; see https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories
git remote add myfriend git://github.com/myfriend/qtlHD.git
In .git/config:
[remote "myfriend"]
url = git://github.com/myfriendp/qtlHD.git
fetch = +refs/heads/*:refs/remotes/myfriend/*
After pulling from origin, use the following to get access to a branch
only on origin:
git checkout -b mybranch origin/mybranch
======================================================================
Searching github:
https://github.com/search?utf8=%E2%9C%93&q=session_info+filename%3A.travis.yml
======================================================================
bitbucket: Had trouble with ssh; here's what seemed to work
Have the ssh agent running:
ssh-agent
To check if you have any ssh identities:
ssh-add -l
To add the default identities:
ssh-add
To remove all current identities:
ssh-add -D
======================
A couple of things from Software Carpentry
- to get out of detached HEAD state, use "git checkout main"
- to see the files you're ignoring, use "git status --ignored"
=======================
Convert master branch to main
- on github, settings -> Branches, change default branch from master to
main
- locally:
git branch -m main
git push -u origin main
git branch -d -r origin/master
=======================
Updating git for windows, at command line:
git update-git-for-windows