githubschool / tiger-king

Let's learn about Git and GitHub
https://githubschool.github.io/tiger-king/
MIT License
0 stars 0 forks source link

Parking Lot #8

Open whatupfoo opened 4 years ago

whatupfoo commented 4 years ago

Post any questions you may have here during the training.

Tips Don't forget there are resources on the README file of this repository!

Links

GitHub Flow WIP probot CODEOWNERS file

Common git commands

Screen Shot 2020-01-13 at 9 22 12 AM

GitHub Flow that shows two environments (sorry for the crappy visual)

Screen Shot 2020-01-13 at 9 24 55 AM

Day to Day Basic Workflow

  1. Assuming this repository has already been cloned, now you need to bring in new updates from GitHub to incorporate work that has been done by your team
  2. Make sure you're on the master branch - git checkout master
  3. Bring in updates on GitHub with git pull
  4. Now you can bring those updates down to your local feature branch (assuming you already have one, and have started working on it) with a reverse merge -
    git checkout feature-branch
    git merge master
  5. You may have to deal with merge conflicts. Not a bad thing! Just resolve them and move on šŸ„³

Merge conflicts

Screen Shot 2020-04-10 at 10 20 41 AM

Try the following exercise and take note of your observations:

  1. Create a new folder
  2. Make it a git repo with the command git init
  3. Create a new file with touch file1.txt and add a line of text to it
  4. Save, git add, git commit -m ā„¹ļø For now, we are going to rule out branch protection settings & pushing to GitHub

Exercise 1

  1. Create a new branch, and name it say, "branch1"
  2. Edit file1.txt at the same line
  3. Save and commit the change
  4. Merge the branches with git checkout master and git merge branch1. This merges branch1 into master.
  5. What type of merge is this? Did it cause a merge conflict? Why or why not?

Answer

- It's a fast forward merge - It does not cause a merge conflict even though the same line has been edited. Because `master` has not diverged from `branch1`

Exercise 2

  1. Continue with the last exercise.
  2. Let's add another line to file1.txt, say on line 2
  3. Save and commit the change
  4. Go back to master branch with git checkout master
  5. Add a different text for line 2
  6. Save and commit the change
  7. Merge branch1 into master again with git merge branch1 What happens this time?

Answer

- This is a merge commit. When 2 branches have diverged, they merge with the merge commit strategy. - This causes a conflict if it touches the same line because the branches have diverged

Revert

The question asked during the class was: What if you revert a file that has a conflicting line of code with a previous commit?

A revert undoes everything you did in that single commit. So it will undo that line of code, and return to the previous line of code in the previous commit.

To demonstrate what I mean, you can try it out:

  1. Create a repository with git init
  2. Create a file and add line 1, save and commit, let's call this commit1
  3. Open the file again and change line 1, save and commit, let's call this commit2
  4. Revert commit2.
  5. Notice how your file shows the line you had in commit1
bearntrail commented 4 years ago

How long will this githubschool/tiger-king repository be around after the class? ā²ļø

response

Hey @bearntrail - I believe it'll be here until our team decides it's time to clean up and it's rare for us to do so. But if you want to make sure you always have this, you can always fork this to your personal account to keep a copy.

nchalakova commented 4 years ago

$ git checkout -b nchalakova -add-caption error: unknown switch `a'

response

hey @nchalakova šŸ‘‹ So this is caused by the extra space after nchalakova - if this removed, it would solve the issue

cousinnu commented 4 years ago

Is the commit comment permanent or can it be modified?

reponse

Hey @cousinnu šŸ‘‹ Good question - There are ways to modify commits, but there are some caveats to that since every single person on your team will share the same history. Tomorrow, if we get to advanced stuff, we can look more into it changing commit history.

nchalakova commented 4 years ago

I have an issue: Nelly@Nelly-HP-PC MINGW64 /c/tiger-king/_posts (nchalakova) $ git add 0000-01-11-nchalakova.md

Nelly@Nelly-HP-PC MINGW64 /c/tiger-king/_posts (nchalakova) $ git status On branch nchalakova nothing to commit, working tree clean

response

Hi @nchalakova - I think I have to see the previous history to know what you have nothing to commit. Either you didn't make any changes, or maybe forgot to save? There could be a lot of reasons, if you don't mind, can you share the previous commands you did before these couple ones? Thanks!

whatupfoo commented 4 years ago

Saving history of git bash

This is the command to run history > file_name.txt

mstrelau commented 4 years ago

If anyone is interrested, here is the log of my git session as I followed along with Rowena.

Marks git class Day 1 session.docx

mstrelau commented 4 years ago

whoops - reopened.

whatupfoo commented 4 years ago

@mstrelau šŸ‘‹ Thanks for sharing!