Repository navigation
Expand file tree
/
Copy pathbasics_of_git.txt
More file actions
54 lines (40 loc) · 3.29 KB
/
Copy pathbasics_of_git.txt
File metadata and controls
54 lines (40 loc) · 3.29 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
Before you start doing work
1. git checkout main
2. git pull
3. git checkout Jessica
4. git pull origin main
When you are done coding some things and want to upload them
1. git add .
2. git commit -m "your message here"
3. git push
4. click on link and click green buttons on GitHub
5. go back to terminal
6. git checkout main
7. git pull
8. git checkout Jessica
9. git pull origin main
Two ways to do git stuff: in the terminal, and with the Git user interface.
I prefer the terminal but you may find the Git GUI to be more intuitive.
Terminal
1. Use the Windows Explorer to navigate to the folder where you are storing the project files.
2. Right-click anywhere within the folder (not on a file) and choose "Open in Terminal".
All commands should have "git" preceding it.
- "status" tells you the current status of your files compared to files in the git repo. It will tell you if you have added, deleted, or modified any files since the last time you synced your local repo with the git repo.
- "fetch" will check if the git repo has changed since your last sync, but does NOT sync your repo
- "pull" will apply any changes made to the git repo to your repo (NOT the other way around)
- "branch" will list your currently active branches
- I won't bore you with the details about branches, but it is good practice when working with multiple people to create your own branch before making changes to your repo
- "branch [name]" will create a new branch with the name that you give it
- "checkout [name]" will switch you to the branch of your choosing (assuming it exists)
- "branch -d [name]" will delete the chosen branch (NEVER delete main)
- "add [files]" will stage files that you have added, deleted, or modified - this means to prepare the files for uploading to the git repo
- "commit -m [message]" will take prepared files from the previous command and actually get ready to upload them (not sure why there are two steps here), and associates a message with the commit, which should describe what you did (the message should be within quotation marks)
- "push" will actually upload files you have added and committed to the git repo
- Make sure you do add, commit, and push while on your personal branch, NOT on the main branch
- The first time you do this with a new branch, git will say to run another command about setting upstream. Just copy, paste, and run this command and you should be good for future pushes.
- Once you have pushed, you'll need to go to the GitHub page and a message will show up at the top with a button saying "Compare & pull request", click that. Then click on the green button that says "Create pull request".
- Here, you could run into merge conflicts if the changes you are making conflict with changes that I have made and pushed to the repo before you. You should be able to choose which changes to keep and which to drop here. Once you have resolved all conflicts, or have no conflicts to begin with, click "Merge pull request" and "Confirm merge". Finally, click on "Delete branch".
- Return to the terminal, checkout the main branch, delete the branch you just came from, and pull
Git GUI
1. Use the Windows Explorer to navigate to the folder where you are storing the project files.
2. Right-click anywhere within the folder (not on a file), choose "Show more options", and choose "Open Git GUI here".