14:17:12 #startmeeting Fedora Classroom (2017-10-05) 14:17:13 Meeting started Thu Oct 5 14:17:12 2017 UTC. The chair is FranciscoD. Information about MeetBot at http://wiki.debian.org/MeetBot. 14:17:13 Useful Commands: #action #agreed #halp #info #idea #link #topic. 14:17:13 The meeting name has been set to 'fedora_classroom_(2017-10-05)' 14:17:32 #meetingname fedora-classroom 14:17:32 The meeting name has been set to 'fedora-classroom' 14:17:44 #meetingtopic Git 101 14:17:49 \help 14:17:56 sorry :) 14:18:00 no worries :) 14:18:18 OK, before we begin, please check that you have git installed 14:18:24 on Fedora, that's `dnf install git-all` 14:18:38 We'll stick to the command line, and you can explore other UI frontends later 14:18:53 Please also log in to Pagure at pagure.io - when we work with remotes, we'll use Pagure 14:19:19 Let's take 5 minutes to do all of this, and in the meantime, you can introduce yourselves if you'd like :) 14:19:23 #topic roll call 14:19:26 .hello ankursinha 14:19:27 FranciscoD: ankursinha 'Ankur Sinha' 14:19:39 That's me - if you have a Fedora account, you can use that command :) 14:21:03 .hello venkateshkareti 14:21:04 prime_: venkateshkareti 'None' 14:21:26 .hello2 skamath 14:21:28 skamath: skamath 'Sachin S Kamath ' 14:22:08 * skamath had gone for dinner but is back now 14:23:25 OK, let's proceed then 14:23:33 #topic Version control 101 14:23:42 #chair skamath 14:23:42 Current chairs: FranciscoD skamath 14:23:52 I take it everyone here codes a bit? 14:24:03 Yes we do 14:24:06 print("Yes") 14:24:14 Now, when you work with lots of files, and you make lots of changes, tracking all these changes becomes quite hard 14:24:24 I know people that make new folders each time they make a change 14:24:33 but well, that doesn't scale very well.. 14:24:54 So, brainy that programmers are, they made tools to handle source code 14:25:09 Here is a bonus image before we start : https://i.redd.it/05b6u19pseoz.png 14:25:17 There are many of these - from the older CVS to the new ones - svn, git, hg 14:25:34 and perforce and others that aren't open source (weren't the last time I checked) 14:26:05 These tools are designed for various "software development strategies" - that you can learn via Google 14:26:09 (or a coursebook) 14:26:18 Agile is one that's very popular nowadays 14:26:23 * skamath learns that in $univ 14:26:37 "Waterfall" is another classic one that skamath must have been taught ;) 14:26:46 lol yes 14:26:56 In short, use version control - whatever tool you prefer, but learn it, and use it 14:27:28 Oh, by the way - if you have a question at any point, please use "!" or "?" to grab my attention 14:27:36 Any questions till now? 14:27:53 nope, all good 14:28:00 For late comers - please install git, and log in to pagure.io 14:28:03 !no 14:28:07 #info For late comers - please install git, and log in to pagure.io 14:28:19 #info use version control - whatever you prefer, but use it 14:28:28 On to Git then 14:28:33 #topic Git! 14:28:57 First - even before I begin - where do you get help? 14:29:07 #info Help on git: 1. https://git-scm.com/ 14:29:15 #info Help on git: 2. the man pages 14:29:35 everyone open a terminal - and run `apropos git` 14:29:42 tell me what you see! 14:29:57 git: nothing appropriate. 14:30:02 a lot of text 14:30:19 ha33, have you installed git? 14:30:25 matrix text ;) 14:30:27 yeah 14:30:31 man pages 14:30:31 "nothing appropriate" 14:30:40 should have a problem here xD 14:30:49 list of commands 14:31:02 ha33: try `man -u` - maybe your mandb isn't built yet 14:31:09 dtate_: try the same thing ^ 14:31:30 wait, that command is incomplete 14:31:32 * FranciscoD goes to check 14:32:00 `sudo mandb` 14:32:07 that'll update your man page database 14:32:12 I have the man page for git... 14:32:31 Though git version is 2.9.5 14:33:04 dtate_: that shouldn't matter as long as you have the docs installed 14:33:04 For people who just joined : please install git, and log in to pagure.io 14:33:28 k 14:33:29 probably the `git-core-doc` package 14:33:33 ha33: Do you have all of git installed? I've been using git for a while but 'sudo dnf install git-all' installed several more packages that were not previously on my system.. 14:33:42 now it's showin a list of comments 14:33:56 commands* 14:33:56 Newcomers : Sign up for a FAS account if you have not already : https://admin.fedoraproject.org/accounts/user/new 14:34:02 rm_: ++ -> git-all pulls in a majority of the available git modules 14:34:12 skamath: although an FAS is not compulsory 14:34:28 FranciscoD, it is required for logging into Pagure 14:34:29 no? 14:34:37 skamath: I thought anything openid, not sure 14:34:48 Anyway, we'll see to that later 14:34:54 k. git-all installed 20 more packages. 14:35:03 Hello : ) 14:35:09 #info `apropos` goes through all your man pages and finds ones that match the search term 14:35:17 And now I have a wall of text from `apropos git` 14:35:18 so you'll see there are a *lot* of man pages for git related tools 14:35:22 FranciscoD, afaik a fas account is required. 14:35:27 dtate_: ah, yeh, that's what you should get 14:35:45 if you try `apropos git-` (add the dash), that may shorten the list a bit 14:35:46 sounds like I missed a lot! 14:36:03 mido, No you've not :) 14:36:24 Install git if you have not already and login to pagure.io 14:36:29 could you just give me a breif then?. 14:36:32 We are just warming up. 14:36:34 I already did 14:36:35 great 14:36:39 In summary, there is extensive documentation on your machine - you don't even need to go online 14:36:51 FranciscoD wanted you to run apropos git and report what you see here. 14:37:12 try: `man git`, see what it says 14:37:24 use the arrow keys to scroll, and q to quit the man page 14:37:33 We are learning about a *stupid* content tracker? :( 14:38:04 skamath: computers are inherently stupid 14:38:14 they do exactly what you ask, even if what you're asking is illogical 14:38:19 ;) 14:38:53 apropos git and man git what is the deference? 14:39:03 the rogue AI will not forgive you for this (someday) ;) 14:39:04 logged in to pagure and opened man git 14:39:15 but I've no idea about pagure 14:39:20 mah0x00: apropos give a list of all available man pages that match your search query, in this case "git" 14:39:26 it worked for me though, thanks FrancicsoD and rm_ 14:39:28 mido, awesome. You're on track now. We'll get to it. 14:39:32 mah0x00: `man git` opens up the man page 14:39:54 of course, if you're new to man pages, at some point, you should read `man man` 14:39:57 ;) 14:40:21 the ultimate recursion ... 14:40:31 skamath, how do you color the message btw :D 14:40:36 ha, yeh, but thankfully, it ends there :) 14:40:47 mido, did I? 14:40:49 pagure is similar to GitHub! right 14:40:58 Let's close the man pages, and do some version control then? 14:41:06 oh, yea 14:41:10 yea! I'm so excited 14:41:24 #info Help with Git 3. Google (of course) 14:41:25 ah yeah :D 14:41:41 its in green when you type my name 14:41:42 if you ask others, they'll point you to LMGTFY 14:42:04 mido, That's highlight when someone mentions your nick. 14:42:04 http://bfy.tw/QI 14:42:11 try that ^ 14:42:16 FranciscoD, that's what I do. Always. 14:42:18 :P 14:42:31 skamath, great! 14:42:34 LD 14:42:35 :D 14:42:42 That came up as green for me ;) 14:42:58 (or DuckDuckGo) 14:43:12 #topic Getting our hands dirty! 14:43:14 skamath sounds cool ;)...my first time actually haha 14:43:25 OK, open a terminal 14:43:29 Hello, just created a FAS account and logged in at pagure.io 14:43:34 `cd` to a convenient directory 14:43:37 rakya77++ 14:43:41 rakya77, Awesome! You're on track :) 14:44:00 and create a new directory: `mkdir somethingsomething` 14:44:00 FranciscoD, done! 14:44:04 Done 14:44:08 replace somethingsomething with a suitable name, of course 14:44:21 Done 14:44:22 +1 14:44:22 enter this directory 14:44:31 this is where, we'll keep our source files 14:44:48 great 14:45:00 Now, we must tell Git that we want it to manage this directory, so we "initialise" a "git repository" 14:45:03 `git init` 14:45:18 then try: `ls -lash` 14:45:27 done. 14:45:30 and also try: `tree .git` 14:45:37 I see it created a .git folder 14:45:44 dtate_: lovely! 14:45:46 \o/ 14:46:07 Remember, if you run into trouble, let us know using "!" or "?" 14:46:11 Good stuff! 14:46:32 This .git directory is where git stores metadata about your files 14:46:51 It's the secret saviour of your folder. 14:46:57 you rarely need to edit it by hand - usually you'll use a git command to do it for you 14:47:15 #info Try not to modify the contents of `.git` by hand 14:47:23 Unless you really know what you're doing, of course :) 14:47:31 Ok... no touching..;) 14:47:40 Should we add a file then? 14:47:45 How about a shell script? 14:48:08 The hello world echo? :) 14:48:10 Use your favourite text editor to create a new file in this directory 14:48:13 skamath: you know it ;) 14:49:02 ?What kind of file, .txt, .sh? 14:49:07 Tim__: .sh 14:49:19 I called mine `Git101.sh` 14:49:27 Add these lines to it: https://paste.fedoraproject.org/paste/9t3qRA0vW~sm2LtADqY9sw 14:49:34 done, mine is file1.sh 14:50:01 helloworld.sh 14:50:17 save it, close it 14:50:25 +1 14:50:29 mine is also git101.sh 14:50:33 To run a shell script, you need to make it executable: `chmod +x ` 14:50:42 replace with whatever filename you used 14:51:16 it's looking green now :) 14:51:19 then, run `ls -lash`, and you should see that it is now executable 14:51:45 aditya_r: yeah, different terminals use different colours to show them :) 14:52:02 Newcomers : Install git, log on to pagure.io, open terminal and `mkdir `, `cd `, `git init` to initialize a git repo and `ls -lash` to see what changed. 14:52:06 These will be the permissions: `-rwxrwxr-x` 14:52:21 You can read up on them later - Google, man ls, and so on :) 14:52:40 +1 14:52:44 now run the file: `./` 14:52:58 It'll simply "echo" the message you asked it to 14:53:09 Let me know with a +1 when you've done this 14:53:15 +1 14:53:16 +1 14:53:16 +! 14:53:21 +1 14:53:22 +1 14:53:23 +1 14:53:27 +1 14:53:28 Please stop me if I'm going too fast for you too :) 14:53:29 +1 14:53:31 +1 14:53:31 +1 14:53:32 +1 14:53:34 Wow. 14:53:35 +1 14:53:54 +1 14:54:06 +2 14:54:08 +1 14:54:14 Anyone in trouble? 14:54:15 +1 14:54:16 +1 14:54:21 Remember, there are *no* stupid questions 14:54:42 In the worst case scenario, I'll ask you to Google it ;) 14:54:57 Why not Bing? 14:55:00 :) 14:55:11 Tim__: ah, yes, $search_it 14:55:23 Google has become a placeholder for searching, hasn't it :P 14:55:36 -e^i\pi 14:55:47 woah 14:55:51 *shivers* bing... 14:56:03 OK, now that we have a file, we want to tell Git that it should monitor it 14:56:15 Try: `git status` 14:56:30 It'll give you information on the current state 14:56:44 git status 14:56:52 It even suggests what you can do 14:56:56 Untracked files ...... 14:56:58 black3dynamite: in your terminal ;) 14:57:08 nothing added to commit but untracked files present (use "git add" to track) 14:57:25 Exactly, so git has seen that there's a file that it isn't yet tracking 14:57:27 exit 14:57:32 Let's tell git that we do want it to track it 14:57:36 `git add ` 14:57:39 Yeah, I just notice that. :) 14:57:56 black3dynamite: happens to me all the time :D 14:58:07 after you've added it, check status again 14:58:14 something should've changed 14:58:19 green :) 14:58:21 it is green now 14:58:30 and, the message above it now says? 14:58:40 Changes to be commited: 14:58:46 (use "git rm --cached ..." to unstage) 14:58:46 new file: hello.sh 14:59:03 ^ 14:59:03 Tim__, don't do that yet. 14:59:32 Great - anyone see something different? 14:59:44 It's green and says new file. 14:59:53 +1 15:00:15 Yes - so what we've done is "staged" the file 15:00:16 +1 15:00:26 +1 15:00:28 this means that git is not watching the file for changes 15:01:01 In Git, you stage changes 15:01:04 now* :) 15:01:12 FranciscoD, not watching? 15:01:17 ? not watching? 15:01:26 oh, yeh - now watching 15:01:28 oops 15:01:29 XD 15:01:32 FranciscoD: ack 15:01:34 \o/ 15:01:56 I thought my whole life was a life and cross verified. 15:02:01 s/life/lie 15:02:03 lol 15:02:09 so each time you make some changes, you *stage* them 15:02:22 and then, you can "commit" these changes 15:02:25 let's try that now 15:02:38 `git commit -m "first commit"` 15:02:42 There we go. The initial commit! 15:02:55 then, check status again 15:02:57 +1 15:03:10 what is '-m'? 15:03:29 git: "on branch master\n nothing to commit, working tree clean" 15:03:37 ? it says : tell me who you are???? 15:03:39 eeveryone that wants to know what "-m" does -> `man git-commit` 15:03:40 +1 "nothing to commit, working tree clean" 15:03:53 man git 15:04:10 ! 15:04:10 same as prime_ 15:04:10 FranciscoD, If it is the first time, they will have to git config user.email and user.name 15:04:11 prime_: haha - if it's optional, you can skip that. It's asking you to mention your username and e-mail etc 15:04:31 skamath: yeh - been a long time since my "first time" with git 15:04:44 Hahah, same. Even I just realized that. 15:04:49 I thought it just took the current user 15:04:54 mah0x00: yeh? 15:04:59 FranciscoD, it will still require an email address. 15:05:10 skamath: nah, that's optional surely 15:05:15 so do i do as it say 15:05:24 If it's new, it uses yoru loginname@computername.domain 15:05:30 It will be a problem later on if you don't configure now. Pagure won't recognize you 15:05:32 Yep. 15:05:36 yeh, sure - I'll make a note at the end on how to modify it 15:06:11 OK, let's do this then, but I won't explain it for the moment 15:06:24 Everyone create a new file in your home directory: `~/.gitconfig` 15:07:01 aditya_r: For those wondering, the `-m` switch allows you to specify a message on the commit line. 15:07:23 dtate_, I got it thanks. 15:07:34 I have done with commit. 15:07:36 and in that file, add this: https://paste.fedoraproject.org/paste/9JxLl4kg7xYKFF-G6sAw1Q 15:07:55 It's saying master (root-commit) c51419c] first commit 15:07:58 if the file exists, edit it if you want 15:08:03 aditya_r: that's correct 15:08:25 Everyone at the commit? 15:08:37 yup 15:08:44 +1 15:08:49 +1 15:09:04 ? is it possible to create multiple users in .gitconfig , letsay one account for pagure and one for github? 15:09:12 +1 15:09:17 +1 .gitconfig file created and edited, then saved. 15:09:34 +1 15:09:48 capitanocrunch_, Instead of setting it globally, you can also have repo based settings 15:09:57 capitanocrunch_: that's the global file, so that'll only have one, but for each repository, you can have different settings 15:10:00 as skamath just sid 15:10:05 what shoudl we add to .gitconfig file? 15:10:24 prime_: https://paste.fedoraproject.org/paste/9JxLl4kg7xYKFF-G6sAw1Q 15:10:36 ++ FranciscoD skamath 15:10:54 ? And that file goes in /home/, correct? 15:10:57 OK, so we've initilised a repo, we've staged changes, and we've committed changes 15:11:06 can you give 5 min i want to configure git for the first time use according to https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup 15:11:10 +1 15:11:11 Tim__: yes, `~/.gitconfig` would be the short cut 15:11:24 mah0x00: you can delete the file and do it again later :) 15:11:45 Now, try: `git log` 15:11:47 ok 15:11:52 git log 15:12:00 +1 15:12:02 Question: Iss this meeting topic purely done by text communication? 15:12:21 shyzus: yep, it is only over the IRC 15:12:28 It gives me a yellow hash , author, date, and the commit message 15:12:54 Everyone, let me know when you see details of the commit 15:13:00 +1 15:13:02 +1 15:13:03 After 'git log' it's showing my first commit id. 15:13:04 +1 15:13:05 +1 15:13:08 +1 15:13:13 +1 15:13:14 +1 15:13:20 +1 15:13:25 * FranciscoD will wait a minute 15:13:30 This bit is important :) 15:13:55 +1 15:13:59 Is anyone in trouble in the meantime? 15:14:14 * FranciscoD will continue at 16:15 (about 45 seconds) 15:14:43 +1 15:15:14 +1 15:15:15 OK, so what you see is information on your commit 15:15:28 the first line gives you the "hash" of the commit 15:15:50 Author Name 15:15:53 Each commit will have a unique hash 15:15:59 Date 15:16:06 and commit. 15:16:27 Yes, and then, it'll give you information about this particular commit - the author of this commit, the date, and the commit message 15:16:39 aditya_r: the whole thing, including the files you added is the commit 15:17:12 FranciscoD, yes. 15:17:20 commit messages are important - Google "How to write a good git commit message" for tips 15:17:23 er.. $search 15:17:37 What does `git show` tell you? 15:17:37 :) 15:18:10 commit same info as log and the code 15:18:23 krilen: the *diff* to be more precise 15:18:31 it tells you the contents of the commit - what changed 15:18:42 includes the code in green lines with `+` in front of each line 15:18:48 the `/dev/null` implies that the file didn't exist before 15:18:55 this: diff --git a/Git101.sh b/Git101.sh 15:18:57 ? 15:18:57 'git show' showing git commit + file detail. 15:19:15 krilen: that's the command that it's running - `a` is before the commit, `b` is after the commit 15:19:29 so a "diff" between the two states 15:19:54 You also have a "diff" command that's independent of Git, by the way 15:20:14 #info Homework: Search the web to learn tips on writing good Git commit messages 15:20:30 #info Homework: read `man diff` (or search the web) 15:20:49 Now, make a change to the file 15:21:15 add a new line, or change the message, or delete the line 15:21:16 ? so if I commit multiple times will it show diff between all those or just the previous and lastest commit 15:21:42 rakya77: `show` shows all commits in sequence, but there are ways to see diffs between particular commits and so on 15:21:51 rakya77: more homework for you ;) 15:22:01 thank you :) 15:22:08 When you've changed and saved the file, try `git status` again 15:22:26 Let me know if you see something new 15:22:38 in red it now says "modified: git101.sh" 15:22:40 +1 - modified and red text 15:22:43 yeah, file modified 15:22:51 +1 modified 15:22:59 Does it also tell you what to do if you want to discard these changes? 15:23:04 +1 modified 15:23:09 try that 15:23:12 yes 15:23:16 +1 15:23:23 git checkout yes, git checkout 15:23:26 git checkout 15:23:34 check status again 15:23:36 done. 15:23:51 now it says nothing to commit. 15:23:57 It changed the file back 15:23:59 +1 15:24:05 Good - because we asked it to :) 15:24:15 nothing to commit, working tree clean 15:24:18 *panics* did I loose all my hard work? /s 15:24:25 back before the modify 15:24:30 +1 lost changes 15:24:55 dtate_: well, yes, in this case, you did :D 15:24:59 echo 'echo "Git is goooood"' >> 15:25:16 then do `git diff` - see what it says 15:26:06 has a diff of the old file and the file with the newly added line 15:26:14 added the new line to the file 15:26:16 +1 15:26:24 +1 15:26:28 OK, stage the changes 15:26:42 using `Git add` 15:26:52 +1 15:26:56 try diff again 15:27:01 what now? 15:27:13 empty 15:27:14 nothing 15:27:16 nothing 15:27:18 diff gives nothing and status is green 15:27:22 `git diff --cached`? 15:27:39 I have the diff of the new line now 15:27:47 shows the change +green 15:27:56 Tim__, same 15:28:00 So, diff by default shows *unstaged* changes 15:28:07 Oh thats great option to know... 15:28:17 when you've staged a change, git now knows about it, so you need to give a --cached flag to see them 15:28:24 Go ahead and commit this change 15:28:43 +1 15:28:48 +1 15:28:51 +1 git diff shown nothing. But uisng git diff --cached worked. 15:28:52 check the commit log again: git log 15:29:06 check `git show` again 15:29:06 +! 15:29:10 +1 15:29:13 +1 15:29:13 aditya_r: question? 15:29:18 no 15:29:18 ah, no worries :) 15:29:23 +1 15:29:29 +! 15:29:31 +1 15:29:36 +1 15:29:46 Now it commited with the correct email, also. 15:29:48 +1 15:29:48 now, try this: git show 15:30:31 ? 15:30:35 So it gave me the diff of the original file. But not the newly added line. 15:30:42 aditya_r: find the hash of the first commit you had made 15:30:56 dtate_: good - it shows you what that particular commit had changed, right? 15:30:58 aditya_r, find the commit hash from the log 15:31:11 yes it does 15:31:12 yes 15:31:15 done 15:31:26 Excellent! 15:31:40 OK - run `git log` again - does it say "(HEAD -> master)" on top for you folks? 15:31:42 +1 15:31:47 +1 15:31:53 (It does for me, but I may have configured it to say so) 15:32:07 no 15:32:11 no 15:32:17 yes 15:32:20 It does beside the latest commit 15:32:38 dtate_: ha33 : check again, right at the top next to the commit hash? 15:32:44 +1 15:33:10 no... nothing 15:33:19 same 15:33:24 OK, nevermind 15:33:32 Doesn't it show by default? 15:33:57 skamath: not sure tbh, I thought it did 15:34:11 Yes it showing (HEAD -> master) 15:34:17 try `git log --pretty=full` 15:34:25 weird that it's showing for some, and not for others 15:34:28 Not sure if makes a difference though. 15:34:51 what's the first line in `git status`, though? 15:35:03 Does it say anything about a "branch"? ;) 15:35:14 On branch master 15:35:20 On branch master 15:35:25 For those who are wondering, it looks something like this : https://imgur.com/a/NLdwk 15:35:46 on branch master 15:35:56 Yes - let's work with branches now! 15:35:59 #topic branching 15:36:13 By default, you start with a branch - it's called "master" 15:36:20 this is purely convention - you can change it to whatever you want 15:37:00 `git branch` will tell you what branches you currently have - namely, "master" 15:37:13 to get more info, use `git branch -v` 15:37:21 that will tell you what commit this branch is currently at too 15:37:55 then, create a new branch - you "checkout" a new branch: `git checkout -b newbranch` 15:38:07 'git branch -v' -> master 3a618aa added git is good 15:38:41 after you checkout your new branch, run `git branch -v` again - see the difference? 15:39:00 yeah 15:39:05 so it has the new branch, but the same info 15:39:12 +1 15:39:13 Yes, git checkout -b newbranch -> Switched to a new branch 'newbranch' 15:39:25 all a branch does, is point to a commit 15:39:29 yes master and newbranch 15:39:32 so branches in Git are very cheap 15:39:41 make as many of them as you want, they don't cost anything :) 15:40:03 try this: `git log --graph --pretty=full --all` 15:40:06 Why woudl one create a new branch? 15:40:19 Tim__: I'll show you in a minute ;) 15:40:57 git log --graph --pretty=full --all 15:41:09 also add `--color` at the end, just to be sure 15:41:11 After `git log --graph --pretty=full --all` it showing (HEAD -> newbranch, master) 15:41:25 +1 15:41:31 +1 15:41:37 does it show a line on the left side? 15:41:44 yep 15:41:45 it still isn't showing HEAD 15:41:46 from the old commit to the new one? 15:41:57 yes 15:42:02 +1 15:42:07 +1 15:42:07 +1 15:42:08 dtate_: I'll look at that later - must be a setting somewhere 15:42:13 yepp 15:42:14 k 15:42:18 OK, so we're all on this new branch, agreed? 15:42:23 yes 15:42:25 (HEAD -> test-branch, master) 15:42:31 Create a new file - add another echo, save, stage, commit 15:42:37 I see multiple vertical red line 15:42:40 You'll know how to do that already :) 15:42:52 black3dynamite: that's the ascii way of showing a line from one point to another :) 15:43:04 Good to know 15:43:06 let me know when you've committed a new file everyone 15:43:38 +1 15:44:03 +1 15:44:06 run this again `git log --graph --pretty=full --all --color` - see anything different? 15:44:29 +1 15:45:00 +1 15:45:04 new file with committed showing on new branch. 15:45:06 HEAD -> newbranch (master left behind at previous commit) 15:45:17 ^ 15:45:17 +1 15:45:41 +1 15:45:43 +1 15:45:50 two red lines on the left, one for each branch? 15:45:58 How to switch form one branch to another? 15:46:05 the red line, is creating a "tree" of your commits 15:46:10 it'll get nicer, hold o 15:46:19 aditya_r: ah, yes, let's do that 15:46:28 you simply checkout another branch: `git checkout master` 15:46:47 k 15:46:48 try the full git log command again 15:46:52 what do you see now? 15:47:01 The HEAD -> moved :) 15:47:08 HEAD switched back to master 15:47:10 same thing 15:47:13 +2 15:47:15 +1 15:47:15 \o/ 15:47:19 dtate_: can't be the same thing 15:47:26 Oh, but didn't anyone notice? 15:47:33 That new file you had made - it's gone 15:47:37 ls? 15:47:38 ;) 15:47:48 yes 15:47:53 All my hard work gone? :( 15:47:53 ah 15:48:13 the newfile is gone but the git log is the same 15:48:25 skamath: why don't we quickly switch back to the other branch to check? `git checkout ` 15:48:42 Git saved my life!!! 15:48:45 dtate_: git log --graph --pretty=full --all --color --stat | fpaste 15:48:56 I get into the git class? 15:49:01 Awesome! 15:49:04 FranciscoD, o/ 15:49:05 x3mboy, Welcome. I git init you. 15:49:09 skamath, o/ 15:49:18 #chair x3mboy 15:49:18 Current chairs: FranciscoD skamath x3mboy 15:49:18 Once you're satisfied that tie file is there, switch back to master - create another new file, stage, commit, check log 15:49:34 what happened? 15:49:40 on the newbranch : git log --graph --pretty=full --all 15:49:44 the file is still 15:49:56 on the newbranch: https://paste.fedoraproject.org/paste/kbwhNkLD8oGZFFDOZxQWqg/ 15:50:01 Is git log showing commit of same branch that you switch from? 15:50:45 on the master branch: https://paste.fedoraproject.org/paste/8ZEzYCeRX9iTN-MbyE7GEg/ 15:50:57 aditya_r: git log will show all commits 15:51:03 can you explain what happing 15:51:10 a little 15:51:18 mah0x00: ask me a question - easier that way 15:51:22 dtate_, Are you sure you switched branches? 15:51:34 git status says I did 15:52:02 dtate_: fpaste ~/.gitconfig 15:52:24 ok when i checkout to the master branch the new file gone and when checkout to the new branch the file appears again 15:52:27 why ? 15:52:49 mah0x00: because you only added that file in the new branch 15:53:02 master is still at the previous commit, where the new file doesn't exist :) 15:53:15 FranciscoD : https://paste.fedoraproject.org/paste/0-I31thjCGsIIjmyQ-RmaQ 15:53:17 Everyone, edit your `~/.gitconfig`, and add this: https://paste.fedoraproject.org/paste/Tn5R-cTowdXFICPS41wagg 15:54:04 dtate_: add that too, then try `git lg` and see if that's better 15:54:23 #info 15:54:26 The commands I've asked you to add are "aliases" that display more information in a better formatted manner 15:54:26 #info 15:54:32 mido: info on what? :) 15:54:33 omg sorry! 15:54:38 oh, haha, no worries 15:54:39 I was trying to search 15:54:45 ctrl + f #info xD 15:54:50 +1 15:54:54 mido, info is a command used to log information onto the meeting minutes. 15:55:01 Ah, okay 15:55:05 When you've added those lines, and saved the file, you should be able to use `git lg`, `git lg1` 15:55:08 Been there 15:55:14 try them out - they'd be nicer versions of `git log` 15:55:17 I noticed that its important yeah 15:55:35 I was looking for the similar lines to get the most important things 15:55:43 Let me know when everyone's good with the aliases 15:55:47 sounds like there is home works :v: 15:55:58 FranciscoD : Okay, I got them and they do look nicer. It now shows me which branch my head is on. 15:56:01 mido: there's lots of homework :) 15:56:16 I just did an alias -> alias ls="git status" :D 15:56:29 What. 15:56:30 mido: bad idea - you can't use simple `ls` anymore 15:56:33 +1 15:56:37 thats gonna be cool xD 15:56:46 just inside my git directory 15:56:49 mido, no more ls for you until you clear that. 15:56:51 since I will be using it a lot 15:57:06 to list the changes and etc. 15:57:15 ok I will 15:57:17 mido, you can do alias gst="git status" 15:57:25 great! : ) 15:57:56 +1 15:57:58 Right - after you've checked out master, added a new commit there, do you see that the two branches have now diverged? 15:58:03 use `git lg` 15:58:27 +1 15:58:30 each branch is going a separate way - they're not one after the other any more 15:58:45 Tim__: is the function of branches becoming a little clearer now? 15:59:17 When there are more branches and more commits, the commits for a "tree" 15:59:18 +1 15:59:19 yes 15:59:21 yes 15:59:38 OK, lovely, everyone log in to Pagure! 15:59:45 Yes it is :) 15:59:55 Tim__: there's more, wait for it ;) 16:00:06 k 16:00:14 Log into pagure, click the "+" button in the top right hand corner 16:00:20 https://pagure.io/new 16:00:34 just a little question. so usually when developers want to make a new version based on the previous one, branches is the correct way to do it? 16:00:42 Create a new project called "Git101" 16:01:07 ha33: in the usual workflow, "master" remains the "stable" branch - where code has been tested 16:01:07 +1 16:01:24 different people working on different features will branch off master 16:01:37 work on their branches, and then "merge" back - we'll see that shortly :) 16:01:37 oh i see 16:01:54 On pagure, give the project a name "Git101" 16:02:00 same for description 16:02:17 Leave everything else as it is, click "create" 16:02:37 The project repo "Git101" already exists 16:02:39 The project repo already exist... 16:02:40 The project repo "Git101" already exists 16:02:50 +1 16:02:54 +1 16:03:00 yeh, use: "Git101" 16:03:12 Done 16:03:25 hrm, waiting, that's new :) 16:03:30 Did I get Git101 :) 16:03:36 krilen: I think you did :P 16:03:41 lol 16:03:59 "taking longer than usual" :p 16:04:14 Yeh - while Pagure does its thing 16:04:19 "This is taking longer than usual... Sorry for that" 16:04:27 done 16:04:28 checkout your new branch 16:04:59 +1 16:05:03 +1 16:05:08 try `git merge master` 16:05:23 it'll open a window asking for a commit message - save and quit 16:05:33 yes 16:05:36 if it's VIM, hit `escape` followed by `:wq` 16:05:45 done 16:05:47 (it's probably vi) 16:05:48 done 16:06:21 check `git lg1` again - what do you see? 16:06:24 also check ls 16:06:27 what do you see? 16:06:52 There are now green bars that loop the new branch back into the master branch 16:07:25 and what does `ls` show you? 16:07:37 both files 16:07:50 files from newbranch are now in master 16:07:53 +1 16:07:58 all the files including files 16:08:01 Both files... i'm in newbranch as head 16:08:04 file* 16:08:09 jadupl2_: or is it the other way around? 16:08:35 look at `git lg` -> where is master? 16:08:46 So all the files with the changes are now in newbranch, but not the other way around 16:09:05 dtate_: easy to check - checkout the master branch, see what you've got there :) 16:09:14 +1 16:09:21 yes you are right the other way around 16:09:24 +1 16:09:36 master branch does not have file2 16:09:45 OK, so until now, everything we've done has been on a *local* repository 16:09:52 on your machine 16:09:58 no one else has access to any of it 16:10:06 (not yet) 16:10:24 What we've done on Pagure, is create a "remote" repository 16:10:32 #topic Remotes - on Pagure 16:10:52 #info We're using Pagure, but the same applies to Github, Gitlab, Bitbucket 16:11:18 Pagure and all the rest are just "front ends" - underneath, the same thing happens at all of them 16:11:27 Has Pagure finished creating repos for everyone? 16:11:33 yes 16:11:34 yes 16:11:49 +1 16:11:55 OK, in your terminal, type: `git remote -v` 16:12:03 it'll return nothing, because we haven't set one up 16:12:21 +1 16:12:26 So, we add a new remote, as pagure tells you: 16:12:39 the `git remote add ..` line - copy and paste that in your terminal 16:12:51 check `git remote -v` again 16:13:26 origin bla bla fetch 16:13:35 So now I have a line for (fetch) and a line for (push) 16:13:39 Lovely 16:13:43 origin bla bla (push) 16:13:46 +1 16:13:47 Note - the name "origin" is also convention 16:13:54 you can change it to whatever you want 16:14:00 and in a bit, we'll see that, so don't worry 16:14:38 Now, we want to make our remote in sync with our local repository 16:14:51 try: `git push -u origin master` 16:15:07 shouyld we checkout to master branch before 16:15:10 (it'll probably ask you for your pagure password) 16:15:33 jadupl2_: you can, but it won't make a difference 16:15:41 ah, well, pagure is still working on it, I can't push yet 16:15:45 Permission denied (publickey). fatal: Could not read from remote repository. 16:16:02 mine worked 16:16:18 Tim__: public key? Did you set up keys for Pagure? 16:16:26 Done with git push. 16:16:32 nope 16:16:36 OK, everyone try it - mine's still waiting 16:16:54 Permission denied (publickey) 16:17:13 Do you folks have ssh keys set up on your machines? 16:17:15 should i use the https and not ssh? 16:17:22 yeh, use the https 16:17:26 If you are using the ssh:// address you probably need to set up the ssh key 16:17:31 the ssh protocol can only be used with ssh keys 16:17:39 that's good, though - modify the remote! 16:17:59 well, you can remove it and re-add it 16:18:07 or you can use `git remote set-url` 16:18:17 or you can add a new one and call it `origin1` 16:18:20 up to you 16:18:43 git remote is quite helpful ;) 16:18:59 Ah, I managed to push too 16:19:02 Everyone pushed? 16:19:05 +1 16:19:23 Go to the "commits" tab on Pagure, what do you see? 16:19:41 I don't think https push works on pagure. Does it? 16:19:50 skamath: it should, I hope it does 16:19:54 fatal: repository 'https://pagure.io/Git101.git/' not found 16:19:58 I see all three commits to the master branch 16:20:13 last time I tried, it threw a 403. 16:20:16 Tim__: change to what you had called it? 16:20:28 I edited it before posting it publicaly 16:20:37 The requested URL returned error: 403 with https 16:20:47 Yep, https push doesn't work on pagure yet. 16:20:56 You have to set up ssh keys. 16:21:00 skamath: so one cannot use it without ssh keys at all? 16:21:07 Don't think so. 16:21:14 we'll have to move to Github then... 16:21:37 Right, everyone login to Github then :D 16:21:41 let's create another remote! 16:21:43 In Commit section it is showing all commit :) 16:22:02 Very similar - Login, hit the "+" sign on the right hand top corner 16:22:09 "New repository" 16:22:23 hi 16:22:42 Enter any name, click "create" 16:22:45 DonQuixote: hello 16:23:06 Now, you already have a remote named "origin", so you'll have to use a different name 16:23:17 `git remote add github https:.....` 16:23:25 that'll add a new remote called "github" 16:23:30 then verify with `git remote -v` 16:23:33 github worked: "Branch master set up to track remote branch master from origin." 16:23:53 using https url 16:23:54 can i Ask a question ? 16:23:59 DonQuixote: yeh, of course 16:24:48 why i can't edit a commit message? 16:24:57 DonQuixote, You can :) 16:25:30 DonQuixote: it's slightly advanced: https://help.github.com/articles/changing-a-commit-message/ 16:25:34 everyone on github? 16:25:47 you've pushed master, also push your other branch 16:25:55 git push -u 16:26:06 Can I follow along on pagure since that was working for me? or are they vastly different? 16:26:25 dtate_, It's the same. You can continue on pagure :) 16:26:29 dtate_: ++ 16:26:51 thanks 16:27:03 Pushed the newbranch 16:27:32 thanks Francisco :D 16:27:44 OK, great - let's do one last thing 16:28:12 If you're on pagure, go to my repository: https://pagure.io/MyGit101/commits/master and click the "fork" button 16:28:37 If you're on Github, go to my repository: https://github.com/sanjayankur31/Fedora-classroom-Git-101 and click the "fork" button 16:28:43 let me know when you've done that 16:28:59 done 16:29:28 +1 16:29:50 +1 16:30:07 +1 16:30:13 +1 16:30:23 What you've done is duplicated my repository 16:30:30 you have your own copy of my repo now 16:30:57 This is also why git is great - everyone working on a project has their own copy of the code 16:31:06 so if github or pagure goes down, say, we all have our copies 16:31:21 it's a *distributed* version control system 16:31:23 OK? 16:31:27 cool 16:31:31 +1 16:31:39 So, you have a copy of my repo - but of my remote only 16:31:47 you need to "clone" it to make a local copy 16:32:02 in your terminal, cd out of your earlier local repo 16:32:33 +1 16:32:45 then find the repo's git url - on pagure, this is in the right hand bar 16:32:58 on github, click on "clone or download" 16:33:06 git clone 16:33:22 where before you had "pushed" to a remote, you are now "cloning" a remote 16:33:39 +1 16:34:03 copy that url? 16:34:04 +1 16:34:15 Tim__: yes, that's the git URL to the remote 16:34:39 Also, when you clone a fork, the origin remote is set the URL of your fork and not the parent repo. 16:34:51 +1 16:34:51 +1 16:34:51 ^This is something I found confusing when I started off. 16:34:52 +1 - ls -lash shows your "Fedora-classrom-Git-101" folder 16:34:59 Tim__: lovely, it worked 16:35:09 everyone, enter the folder you just cloned 16:35:26 +1 16:35:27 (btw, you can do git clone to change the name of the folder) 16:35:41 Now, if you run `git lg`, you should see *my* commits :D 16:35:55 See em? 16:35:58 +1 16:36:04 +1 16:36:21 +1 16:37:08 If you're on pagure, try this: `git remote add upstream https://pagure.io/MyGit101.git` 16:37:10 skamath: too late? 16:37:21 pingou, No :) 16:37:25 Looks different than mine. It doesn't seem like my master branch merged into my newbranch 16:37:32 Everyone, pingou is the developer of Pagure :) 16:37:52 one of :) 16:37:55 pingou, there were difficulties pushing via https. 16:37:57 if you're on Github, try this: `git remote add upstream https://github.com/sanjayankur31/Fedora-classroom-Git-101.git` 16:38:09 that's expected, pagure doesn't support pushing via https :) 16:38:12 Tim__: yeh, because we've done different things with our repos :) 16:38:19 FranciscoD hates ssh :P 16:38:34 I don't, but not everyone here has keys yet :) 16:38:49 nice to meet you pingou 16:38:55 After you've set up the new `upstream` remote, verify using `git remote -v` 16:39:03 hi dtate_, same here 16:39:31 pingou, It'd be great to know why. Even I am curious why. 16:39:36 *now 16:39:46 You'll all have 2 remotes (at least) - one of your fork, and one for my "upstream" 16:39:59 have it 16:39:59 skamath: why it doesn't support https? 16:40:03 +1 16:40:04 pingou, yes 16:40:19 +1 16:40:22 skamath: because no-one invested time to figure out how to make it work? :) 16:40:26 +1 16:40:37 Sounds reasonable :p 16:40:43 Thanks! pingou++ 16:40:44 OK, now, create a new branch, call it "feature-X" 16:40:54 branch off master, by the way 16:41:02 remember - branching points matter ;) 16:41:30 +1 16:41:31 skamath: iirc, gitolite does allow it, but I have no idea how 16:41:40 error: pathspec 'feature-x' did not match any file(s) known to git. 16:41:49 or call it "feature-yourname" rather - you're all going to open pull requests, so that'll be a bit confusing XD 16:41:58 Tim__: git checkout -b branchname 16:42:08 you probably forgot the -b bit 16:42:24 Yup, thanks! 16:42:28 can I rename a branch? Or should I just make a new one with the name? 16:42:30 happens to me quite a bit 16:43:07 dtate_: you can move it, sure `-m`, but make a new one anyway 16:43:12 remember - branches are *cheap* 16:43:15 k 16:43:33 Won't empty branches cause clutter? 16:43:49 Tim__: they're not empty, they're pointing to the same commit 16:44:01 you can remove them afterwords 16:44:51 In this new branch, add a new file - yourname.txt - in it say something like `Hello from London!` - stage, commit, push 16:45:31 Then go to your fork on pagure/github 16:45:55 Let me know when you've pushed and gone back to your fork :) 16:47:37 in the browser, that is 16:47:38 done 16:48:03 On github, it'll display a message at the top on the lines of "Compare and pull request" 16:48:19 when in your "local" remote fork... are we pushing origin or upstream? 16:48:39 ? 16:48:44 How do I switch to a fork? 16:48:49 Tim__: you can't push to upstream, you only have "read" rights - you can only push to your fork 16:49:10 rm_: the repo you've cloned is the fork - check using `git remote -v` 16:49:36 Ok.. got it +1 16:49:44 effectively, what you're doing is: you've cloned the main repository for a project, called "upstream" 16:49:49 ? I committed to my new branch "feature-x-name" but it won't let me push it. says "src refspec... doesn't match any" 16:50:01 you are all "downstream" from it 16:50:08 dtate_: tell me the command you used, please? 16:50:22 git push origin feature-x-name 16:50:45 is feature-x-name the right branch name? 16:50:52 `git branch` and check 16:51:05 Your recently pushed branches: feature-tim_ (1 minute ago) 16:51:20 well with the full feature-x-dtate which what I used in the full command 16:51:24 Tim__: and does it say "compare and pull request"? 16:51:38 dtate_: then the branch name is "feature-x-dtate" and you must use that 16:51:57 I did, and it failed. 16:52:24 dtate_: and origin refers to your fork? 16:52:41 oops... you are correct, I typoed "feature" :p 16:52:47 ha, no worries 16:52:56 now I look like an idiot 16:53:19 Tim__: create a pull request? 16:53:23 I used 'git push origin feature-rm' and receive 'permission denied' 16:53:36 rm_: pagure or github? 16:53:39 same as rm_ 16:53:43 github.. sorry 16:53:45 on github 16:53:48 and is origin your fork? 16:54:01 and is it using https? 16:54:04 I thought it was. How do I check? 16:54:08 `git remote -v` will tell you 16:54:50 origin https://github.com/sanjayankur31/Fedora-classroom-Git-101.git (fetch) origin https://github.com/sanjayankur31/Fedora-classroom-Git-101.git (push) 16:55:04 That's the output of git remote -v 16:55:10 (for origin) 16:55:22 ah, and is there another entry for your fork? 16:55:37 You can all only push to your forks - you don't have write access to my "upstream" repository 16:55:58 you can do what you want with your fork, but with the main "upstream" repository, you only have read access. 16:56:05 so push to your fork 16:56:14 git push 16:56:23 done 16:57:10 rm_: work for you? 16:57:15 Tim__: you've already pushed, I gather? 16:57:23 dtate_: pushed to the fork? 16:57:29 yes... 16:57:33 yes I pushed to my fork 16:57:38 and I created a pull request 16:57:46 Ooo - let me check! 16:57:59 The folks on github - create a pull request too 16:58:07 I had origin and upstream with same url > https://github.com/sanjayankur31/Fedora-classroom-Git-101.git , then I removed origin and added origin with my fork url 16:58:14 https://github.com/tjgruber/Fedora-classroom-Git-101/tree/feature-tim_ 16:58:16 rm_: nice! 16:58:21 Not sure if I did it right 16:58:22 OK! FInally! +1 16:58:54 It's in tree 16:59:05 Tim__: go back to the overview of your fork 16:59:26 there, it says "your recently pushed branches" - and on their right, it'll say "compare and pull request" 16:59:47 Folks on pagure - see your pull requests here: https://pagure.io/MyGit101/pull-requests 17:00:07 Folks on github, see them here: https://github.com/sanjayankur31/Fedora-classroom-Git-101/pulls 17:00:17 let's wait for a few minutes 17:01:05 Yes I see my "recently pushed branches" and the "compare and pull request" button. 17:01:17 Tim__: click the compare and pull request one 17:02:03 And then click "Create pull request" button? 17:02:54 yeh 17:03:45 Lovely 17:03:48 I merged them all! 17:04:10 Nicwe 17:04:11 if you look at the commits now, you'll see your commits there too 17:04:25 let's do one last thing and call it a day 17:04:40 git fetch master 17:05:12 git fetch 17:05:13 k. 17:05:15 will do actually 17:06:11 try that now.. 17:06:22 +1 17:06:38 +1 17:06:45 so, you've asked git to "fetch" changes from the upstream remote 17:06:56 nothing will change, you've only "fetched" 17:06:58 OK? 17:07:00 git fetch origin master? 17:07:13 Ok... 17:07:18 Tim__: git fetch 17:07:53 +1 17:08:19 git lg now shows commits from me and others 17:08:46 rakya77: yep, but you'll notice, it'll always say that they're on the remote 17:08:51 your local branches will be unchanged 17:09:05 to apply these to your locals, use this: 17:09:12 git checkout master (to get on master) 17:09:25 git merge /master master 17:09:48 this is asking git to merge the changes that it found on the remote to your local repository 17:09:59 then, try `git lg` - see what happened 17:09:59 +1 17:10:08 One or two things to remember: 17:10:21 always *always* make sure you've updated your local copy to match upstream 17:10:33 because if you make changes, and I've made changes in the meantime, we'll have clashes 17:10:46 so before you open a pull request, make sure you update your fork 17:11:05 did everyone fetch changes from my upstream repo? 17:11:22 +1 17:11:32 +1 17:11:33 +1 17:11:55 +1 17:12:41 Tim__: did that work for you? 17:12:55 now if you push to your fork, you'll update it too 17:13:11 so - a) update your local from my upstream; b) push to your fork to update it as well 17:13:17 I think i need to make a flow chart of commands for this 17:13:23 hahaha 17:13:27 :) 17:13:29 Tim__: hold on, I have one already 17:13:52 Anyway, let's close with lots of homework! 17:13:55 #topic homework 17:14:22 1. Read the git book - https://git-scm.com/book/en/v2 17:14:35 2. Here's an interactive cheat sheet: https://ndpsoftware.com/git-cheatsheet.html 17:14:40 I got it merged: "git merge https://github.com/sanjayankur31/Fedora-classroom-Git-101.git", but if I add /master master or any combination after it< i get error 17:14:48 3. When in doubt, search 17:15:01 Tim__: ah, you don't need to specify the URL there - the name of the remote will do 17:15:29 I should probably info the homework.. 17:15:37 #info 1. Read the git book - https://git-scm.com/book/en/v2 17:15:47 #info 2. Here's an interactive cheat sheet: https://ndpsoftware.com/git-cheatsheet.html 17:15:51 Oh, there's my problem. I dont' knwo the name of the remote 17:15:58 #info 3. When in doubt, search 17:16:04 Tim__: git remote -v :) 17:16:17 #info 4. Another cheatsheet: https://www.git-tower.com/blog/git-cheat-sheet/ 17:16:32 #info 5. Pull requests: https://help.github.com/articles/about-pull-requests/ 17:16:44 #info 6. Good commit messages: https://medium.com/@steveamaza/how-to-write-a-proper-git-commit-message-e028865e5791 17:16:49 okay, according to that it's called "upstream" 17:16:59 https://xkcd.com/1597/ 17:17:05 https://xkcd.com/1296/ 17:17:19 #info 7. Consider setting up keys: https://mikegerwitz.com/papers/git-horror-story 17:17:29 #info 8. Remember the man pages! 17:17:32 Right 17:17:37 I think that's quite enough for one day 17:17:38 XD 17:17:45 skamath: 3 hours today :D 17:17:47 :) 17:17:57 let's close the meeting 17:18:07 Thanks for all of that FranciscoD. I think I learned a lot. 17:18:13 Thanks everyone for coming! :) 17:18:14 Thank you! 17:18:20 thank you :) 17:18:21 if you have an FAS account, let us know! 17:18:26 #endmeeting