Repository navigation
Expand file tree
/
Copy pathlesson_3_reflections.txt
More file actions
84 lines (69 loc) · 5.32 KB
/
Copy pathlesson_3_reflections.txt
File metadata and controls
84 lines (69 loc) · 5.32 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
1 When would you want to use a remote repository rather than keeping all your work local?
Collaboration with others, when you work on multiple machines, when you want a non-local copy of files
2 How do I push changes from local to GitHub repository?
First setup link to GitHub: In the master branch (not sure if this is compulsory), git remote add origin <repository_url>
'origin' is standard naming convention
Then:
git push origin master or git push origin <branch_name>
This pushes the repository files to github. Will prompt for username and pwd if using https
3 What is a remote?
Reference to another repository. When you clone a respository, a remote gets setup for your automatically
4 Why might you want to always pull changes manually rather than having Git automatically stay up-to-date with your remote repository?
Because you may be making changes locally and you dont want git to override the changes with an automatic pull
5 What is a fork?
A fork is a copy of another repository on github - very similar to clone - except it only applies to github. Doesn't require local download of the github repository .. the forked copy stays on github.
6 Describe the differences between forks, clones, and branches. When would you use one instead of another?
fork is a clone of another repository on github
clone is a copy of another repository (locally or hosted somewhere)
branches are labels for a sequence of commits
use fork when you want to work on someone's github project
clone when you want to create a new copy of a repository
use branch when you need to make a change to your code. not sure when to make a branch vs making a commit. branch can consist of several commits.
7 Desribe the pull request process?
push a branch to github
create pull request
collaborators can see that there is a pull request (email notification on pull request)
'pull request' means 'can i merge/push my change into master?' aka 'please merge/pull my request into the master branch'
collaborator can review changes by making a comment (inline comment)
if change is OK, collaborator can click on 'merge pull request' button (only avaialble if no conflicts available)
8 Merging Remote Changes
Git keeps 'origin/master' ie. copy of the github master branch when you pull a change. This is updated when you run 'git fetch origin'. (ie. this fetches commits done by collaborators but does not update your local master)
To merge these changes, run 'git merge master origin/master'
The equivalent of these two commands is 'git pull origin master'. this does both a fetch and merge for you.
9 What is the benefit of having a copy of the last known state of the remote stored locally?
It enables git to merge collaborator's changes when you run a pull (or fetch/merge) from the remote repository
10 What is a process workflow for getting feedback on changes?
Create a branch locally, push branch to GitHub (but dont merge with master yet). push command example: push origin <branch_name>
11 Steps for 'Updating a Pull Request Quiz'
a Create a different-oil branch
git branch different-oil
git checkout different-oil
b Make a commit different-oil changing the oil
subl <file_name>
git add <file_name>
git commit <file_name>
c Push different-oil to your fork
git push origin different-oil
d Create a pull request form different-oil into master
In GitHub click on pull request
12 How would you collaborate without using Git or GitHub? What would be easier, and what would be harder?
Email trails, SMS, custom systems, other online tools eg basecamp
Git/Github seems perfect for code. Git/Github may not be possible with non-tech savvy collaborators or in coding environments where code is not just text files...
13 Q. If I run git fetch and it picks up some changes.. how do I examine those changes?
???
14 When would you want to make changes in a separate branch rather than directly in master? What benefits does each approach have?
It would seem neater to compartmentalise all non trivial changes into separate branches.. so that you can isolate the code for a specific feature in a branch. It allow people to provide feedback on the branch, so it could be good in a team. Has more overhead than working directly on the master.
15 Steps for Updating a Cross-Repository Pull Request (eg when your pull request cannot be merged because of conflicts)
a Add original repository as a remote to your clone - copy URL of repository (eg choose your own adventure master)
b run 'git remote add upstream <url_of_original_repository>' - upstream is a naming convention
c 'git checkout master'
d 'git pull upstream master' - bring your local repos. up to date with original repository master
e 'git checkout <your_conflicting_branch>' ** important
f 'git merge master <your_conflicting_branch>' - merge your branch with master
g this has conflicts, so you have to resolve manually by editing the file(s)
h 'git add <files_modified_by_your_conflicting_branch>'
i 'git commit' - now the branch is merged with the master (see step f)
j 'git push origin <your_conflicting_branch>' this pushes to your own repos on GitHub not upstream which you prob dont permission to
k 'git checkout master' - make sure it also up to date
l 'git push ....' - now the pull request is good to be merged
??? Did not try this myself. Not sure if I could.