mbuf | --------- git session begins ---------- | 15:30 |
---|---|---|
--> vivek (n=vivek@117.201.98.228) has joined #dgplug | 15:30 | |
mbuf | roll call! please tell your name | 15:30 |
kishan | Kishan Goyal | 15:30 |
vivek | vivek | 15:30 |
rtnpro | Ratnadeep Debnath | 15:30 |
--> sunny_slls (n=sunny@125.20.11.34) has joined #dgplug | 15:30 | |
kopecks | koyel banerjee | 15:31 |
parthachowdhury | partha chowdhury | 15:31 |
hermes | Abhishek Sharma | 15:31 |
Meejan | Meejanur Rahaman | 15:31 |
sunny_slls | Sunny Sharma | 15:31 |
abhishekg | Abhishek Gupta | 15:31 |
mbuf | ok, thanks! here after if you need to talk you need to type '!'; | 15:32 |
hermes | cd .. | 15:32 |
mageshcse | magesh | 15:32 |
spechard | Stéphane Péchard | 15:32 |
mbuf | If you haven't downloaded the .pdf yet, please download the presentation from http://shakthimaan.com/downloads/glv/presentations/di-git-ally-managing-love-letters.pdf | 15:32 |
sunny_slls | hi spechard | 15:33 |
mbuf | sunny_slls: don't interpret! | 15:33 |
sunny_slls | mbuf, sorry | 15:33 |
mbuf | today session is an introduction on using git -- a decentralized source control management tool; | 15:33 |
--> zer0c00l_ (n=zer0c00l@117.199.137.176) has joined #dgplug | 15:34 | |
mbuf | this tool is very important for all, because, it helps in your workflows, or the way you are going to work; | 15:34 |
mbuf | I am going to address some basics concepts of the tool, so understanding these are important; once you understand the flow, it becomes really useful | 15:34 |
mbuf | this is not just for source code, but, can be used for your HOWTOs, documentation, assignments, research papers, thesis, and anything text-based that you need to keep track of the history of changes; | 15:35 |
<-- debayan (n=debayan@61.95.198.26) has quit (Read error: 110 (Connection timed out)) | 15:35 | |
no_mind | roll call time | 15:35 |
mbuf | for your projects or documentation you can use http://git.fedoraproject.org/git/ or gitorious.org | 15:36 |
mbuf | no_mind: its been done! | 15:36 |
mbuf | to host your git repos; but, git is very useful to work without Internet connection; | 15:36 |
mbuf | you work with a local copy of the repo in your system itself! | 15:37 |
mbuf | the source of this presentation has also been put in a git repo, which you can get from: http://gitorious.org/di-git-ally-managing-love-letters/mainline/blobs/master/di-git-ally-managing-love-letters.tex ; it has been done in LaTeX and LaTeX-Beamer | 15:37 |
mbuf | --> #n, means slide number 'n' | 15:37 |
abhishekg | mbuf: is it a local repository at localhost | 15:38 |
--> kushal (n=kdas@fedora/kushal) has joined #dgplug | 15:38 | |
mbuf | abhishekg: if you want to talk, type '!' | 15:38 |
mbuf | abhishekg: don't type your message straight away! | 15:38 |
abhishekg | mbuf:! | 15:38 |
mbuf | abhishekg: yes, it is a local repository at localhost | 15:38 |
mbuf | abhishekg: when you are done talking use 'eof'; these were addressed in the previous chat IRC logs; | 15:39 |
mbuf | --> #1 | 15:39 |
mbuf | This is version 1.3 of the presentation; you are welcome to freely re-distribute the presentation or present it to your friends; | 15:39 |
<-- sumitc (n=chatzill@unaffiliated/sumitc) has quit (Read error: 110 (Connection timed out)) | 15:40 | |
mbuf | --> #2 | 15:40 |
mbuf | Please read the 'Warning' | 15:40 |
mbuf | --> #3 | 15:40 |
mbuf | You have to initially define your user.name and e-mail address which will be used in git commits; | 15:40 |
mbuf | --> #4 | 15:40 |
mbuf | these commands update your /home/<your-username>/.gitconfig file | 15:41 |
mbuf | --> #5 | 15:41 |
mbuf | --> #6 | 15:41 |
mbuf | --> #7 | 15:41 |
mbuf | --> #8 | 15:41 |
mbuf | or you can manually update your .gitconfig file; | 15:41 |
mbuf | I have setup a gl alias that I can invoke with git, "git gl" to show the commit logs in the slides; | 15:42 |
mbuf | we will use it in this presentation; | 15:42 |
mbuf | --> #9 | 15:42 |
mbuf | I am only going to show how to manage love-letters, not write love letters :) | 15:42 |
mbuf | working tree defines our local directory structure, / | 15:43 |
mbuf | I am simply creating a directory love-letters | 15:43 |
mbuf | --> #10 | 15:43 |
mbuf | --> #11 | 15:43 |
mbuf | in this top-level love-letters directory, I am initializing a git repo; | 15:44 |
mbuf | it basically creates a .git directory in this top-level love-letters directory | 15:44 |
mbuf | --> #12 | 15:45 |
mbuf | The command and the outputs are shown in different font style formats; | 15:45 |
mbuf | --> #13 | 15:45 |
--> karthick (n=karthick@59.96.30.64) has joined #dgplug | 15:45 | |
mbuf | I am creating a new file called "to-my-dearest.txt" | 15:45 |
mbuf | so the working tree represents what you see in your directory | 15:45 |
mbuf | --> #14 | 15:45 |
mbuf | I am making some changes to to-my-dearest.txt file, by editing it with any editor of my choice; | 15:46 |
mbuf | --> #15 | 15:46 |
mbuf | The index is also known as the staging area; before you commit your love letter you want to stage it (for rehearsal, perhaps) before you commit to your local repo; | 15:46 |
hermes | ! | 15:47 |
mbuf | so any change you make in the files are pushed to index, before committing to the repo; | 15:47 |
mbuf | hermes: shoot! | 15:47 |
mbuf | hermes: yes, what is your question? | 15:47 |
hermes | please elaborate the above 2 lines that u just typed , | 15:47 |
hermes | I dint quite understand | 15:48 |
hermes | eof | 15:48 |
mbuf | hermes: let me finish one iteration, and if you still don't understand, type '!' again; | 15:48 |
hermes | mbuf : alright | 15:48 |
mbuf | so, I have made some changes to to-my-dearest.txt since I created it touch | 15:49 |
<-- zer0c00l (n=zer0c00l@117.199.137.176) has quit (Read error: 113 (No route to host)) | 15:49 | |
mbuf | and before I commit it to my local repo, I am staging it with 'git add' | 15:49 |
<-- no_mind (i=7aa38309@gateway/web/freenode/x-2cf763c7f1d80887) has quit ("Page closed") | 15:49 | |
mbuf | git basically creates object references for the change; everything is stored in .git/ directory | 15:49 |
mbuf | --> #16 | 15:49 |
--> sa111 (i=3b601e40@gateway/web/freenode/x-872bd38ae2dc4a09) has joined #dgplug | 15:50 | |
--> no_mind (i=7aa38309@gateway/web/freenode/x-6f36f204128fe3fa) has joined #dgplug | 15:50 | |
mbuf | that is how you commit the message; as you can see the change is in the repository | 15:50 |
mbuf | --> #17 | 15:50 |
mbuf | --> #18 | 15:50 |
mbuf | --> #19 | 15:50 |
parthachowdhury | ! | 15:50 |
mbuf | You can always check the status of the git repo using 'git status' | 15:50 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 15:50 | |
mbuf | if it doesn't mention any warning, or error messages, your repo status is clean; | 15:51 |
mbuf | so, the basic idea is that one needs to make changes to your local files, add it to the index and then commit it to the repository; | 15:51 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 15:51 | |
mbuf | the use of index, is that if you don't want to commit things to the repo, you can backtrack; | 15:51 |
mbuf | one of the biggest mistakes that newbies do, that I have observed, is that they hack on the same code, again and again and again | 15:52 |
mbuf | so after two days, you ask them to revert their changes to what was two days back, they will not be able to do it; | 15:52 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 15:52 | |
mbuf | but, committing code locally, often and repeatedly, will help one to revert back the commit, or see what changes have been made, and what can be undone; | 15:52 |
mbuf | what are the commands that are used for this workflow between working tree, index and repo is what we will see here today; you may or may not use everything in real-life, but, it is good to know; | 15:53 |
mbuf | parthachowdhury: shoot! | 15:53 |
parthachowdhury | what is 958d5ac ? | 15:53 |
mbuf | parthachowdhury: that is a SHA1 commit number; | 15:53 |
parthachowdhury | ! | 15:53 |
mbuf | parthachowdhury: for every commit you make a unique number is generated | 15:54 |
mbuf | parthachowdhury: wait, let me finish; | 15:54 |
parthachowdhury | ok | 15:54 |
mbuf | parthachowdhury: this is used to identify your unique commit; | 15:54 |
parthachowdhury | is it the object reference ? | 15:54 |
mbuf | parthachowdhury: I said wait! | 15:54 |
mbuf | parthachowdhury: so if someone else copies your repository, which includes the .git repo, and your history of changes, they will see your commit messages; | 15:55 |
mbuf | parthachowdhury: we will not go into git internals, as that is left as an exercise, and not in the scope of this session; | 15:55 |
mbuf | parthachowdhury: git doesn't track files, unlike what cvs and svn do; it tracks content changes | 15:55 |
--> vivek_ (n=vivek@117.201.101.73) has joined #dgplug | 15:55 | |
mbuf | parthachowdhury: so each commit is only info on the change that you have done; | 15:55 |
mbuf | --> #20 | 15:56 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 15:56 | |
mbuf | --> #21 | 15:56 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 15:56 | |
mbuf | so git gl shows use the first commit that we made, with the commit message "FIrst commit" | 15:56 |
hermes | ! | 15:56 |
mbuf | just a brief message to fit in the slide; | 15:56 |
mbuf | hermes: shoot! | 15:56 |
hermes | mbuf : you said that it is a SHA1 commit number which is unique | 15:57 |
hermes | mbuf :what is SHA1 ? | 15:57 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 15:57 | |
hermes | mbuf :eof | 15:57 |
<-- karthick (n=karthick@59.96.30.64) has quit ("Leaving") | 15:57 | |
mbuf | hermes: you can google that? | 15:57 |
sunny_slls | ! | 15:57 |
hermes | mbuf : alright | 15:57 |
mbuf | sunny_slls: shoot! | 15:57 |
<-- vivek (n=vivek@117.201.98.228) has quit (Read error: 104 (Connection reset by peer)) | 15:57 | |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 15:57 | |
mbuf | hermes: http://en.wikipedia.org/wiki/SHA_hash_functions read later! | 15:58 |
sunny_slls | mbuf, suppose i wan't to make some changes in the .txt file | 15:58 |
sunny_slls | but the changes are not done properly so will it backtrack | 15:58 |
sunny_slls | or in other words revert | 15:58 |
mbuf | sunny_slls: we will see those use cases next; | 15:58 |
mbuf | sunny_slls: there is a lot of workflows of what you mean by 'revert' -- everything will be addressed next; | 15:59 |
abhishekg | ! | 15:59 |
mbuf | abhishekg: shoot! | 15:59 |
sunny_slls | also you said about the errors that newbies make | 15:59 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 15:59 | |
sunny_slls | about editing | 15:59 |
abhishekg | I have installed git on opeensuse 11 | 15:59 |
abhishekg | but it doees | 15:59 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 15:59 | |
abhishekg | not have gl | 15:59 |
abhishekg | eof | 15:59 |
zer0c00l_ | ! | 16:00 |
mbuf | abhishekg: this is not the time to answer installation and configuration problems; | 16:00 |
mbuf | abhishekg: you should have put your gl alias in .gitconfig in your home directory | 16:01 |
mbuf | abhishekg: or you could have sent an e-mail to the mailing list group | 16:01 |
sunny_slls | ! | 16:01 |
mbuf | zer0c00l_: shoot! | 16:01 |
mbuf | abhishekg: before coming to the session; | 16:01 |
zer0c00l_ | mbuf, same as abhishekg will correct it <eof> | 16:01 |
mbuf | sunny_slls: shoot! | 16:01 |
sunny_slls | also you said about the errors that newbies make in editing files | 16:02 |
mbuf | sunny_slls: yes; they cannot revert back after changing code; for larger code bases; | 16:02 |
sunny_slls | if suppose we have got make several changes in a file then how can we do it | 16:02 |
mbuf | sunny_slls: all these will be addressed next; | 16:02 |
sunny_slls | ok | 16:02 |
sunny_slls | eof | 16:03 |
mbuf | sunny_slls: first understand the workflow, you can try to use git practically, at the end of the session; | 16:03 |
mbuf | please understand how things work, you can play with git after the session | 16:03 |
mbuf | ask only questions pertaining to the workflow; I shall not take any other questions; | 16:03 |
mbuf | --> #22 | 16:04 |
mbuf | --> #23 | 16:04 |
mbuf | git show gives a more detailed log output, where you can see your username, e-mail given as Author, Date, commit message, SHA-1 number and diff change | 16:04 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 54 (Connection reset by peer)) | 16:04 | |
mbuf | --> #24 | 16:04 |
mbuf | --> #25 | 16:04 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:04 | |
mbuf | always good to check status | 16:04 |
mbuf | --> #26 | 16:05 |
mbuf | Now we try to write a love letter to raaani-mukerji.txt, so I create a new file | 16:05 |
mbuf | --> #27 | 16:05 |
mbuf | 'git diff' shows the difference between working tree and index; | 16:05 |
mbuf | --> #28 | 16:05 |
mbuf | 'git diff --cached' shows the difference between index and HEAD; in other words, it tells whatever will be committed, on the changes that you added to index using 'git add' | 16:06 |
mbuf | --> #29 | 16:06 |
mbuf | 'git diff HEAD' shows the difference between working tree and HEAD; | 16:07 |
mbuf | --> #30 | 16:07 |
mbuf | --> #31 | 16:07 |
mbuf | Since we add a file to working tree, git status is showing that there is an untracked file; tracked files are in the index; | 16:07 |
mbuf | --> #32 | 16:07 |
mbuf | so we add the raaani-mukerji.txt love letter to the index; | 16:08 |
mbuf | --> #33 | 16:08 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:08 | |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:08 | |
mbuf | because nothing was there in index with respect to raaani-mukerji.txt, there s no diff output | 16:08 |
mbuf | --> #34 | 16:08 |
mbuf | --> #35 | 16:09 |
mbuf | because 'git diff --cached' shows what will be committed next, if you commit, it shows the change; | 16:09 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:09 | |
mbuf | --> #36 | 16:09 |
mbuf | --> #37 | 16:09 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:09 | |
mbuf | since we have already added the file to index, 'git diff HEAD' will show the difference because, it also shows what will be committed if you did 'git commit -a -m 'message' | 16:10 |
mbuf | --> #38 | 16:10 |
mbuf | again check git status, to see what git says | 16:10 |
mbuf | now our file is in index, so we can commit as we did with our first commit or we can revert; | 16:10 |
mbuf | --> #39 | 16:11 |
mbuf | --> #40 | 16:11 |
mbuf | raani-mukerji doesn't want to date me; | 16:11 |
mbuf | --> #41 | 16:11 |
mbuf | so we simply try to remove the love letter | 16:11 |
mbuf | --> #42 | 16:11 |
mbuf | because we have staged it to the index, git gives us the error | 16:12 |
mbuf | --> #43 | 16:12 |
mbuf | so we force remove it; | 16:12 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:12 | |
mbuf | --> #44 | 16:12 |
mbuf | --> #45 | 16:12 |
mbuf | --> #46 | 16:12 |
--> djthequest (i=daf85072@gateway/web/freenode/x-1c9fc357ba035987) has joined #dgplug | 16:12 | |
--> sumitc (n=chatzill@unaffiliated/sumitc) has joined #dgplug | 16:12 | |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:12 | |
mbuf | so we see the file has been removed from index and the working tree; | 16:12 |
mbuf | --> #47 | 16:12 |
mbuf | --> #48 | 16:12 |
mbuf | our working tree is clean; | 16:13 |
mbuf | this was a workflow to show a file that you staged and then removed, because you didn't want to keep the file; | 16:13 |
mbuf | --> #49 | 16:13 |
mbuf | Now we try our luck with nayantaara | 16:13 |
mbuf | --> #50 | 16:13 |
hermes | ! | 16:13 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:13 | |
mbuf | hermes: shoot! | 16:13 |
hermes | force deleting essentially deletes the entry from index for 'rani' | 16:14 |
hermes | ? | 16:14 |
hermes | eof | 16:14 |
mbuf | hermes: yes | 16:14 |
mbuf | hermes: and also the file from your folder | 16:14 |
hermes | ya sure | 16:15 |
mbuf | index is only a collection of object references on the changes; | 16:15 |
mbuf | --> #51 | 16:15 |
mbuf | If we just want to remove from the caching staged (index) area, but, still want to retain it in the folder, we can use 'git rm --cached filename' | 16:16 |
mbuf | --> #52 | 16:16 |
mbuf | --> #53 | 16:16 |
mbuf | --> #54 | 16:16 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:16 | |
mbuf | so we now don't have the object references in the index for nayantaaara.txt, but the file exists in the directory; | 16:16 |
mbuf | --> #55 | 16:16 |
mbuf | --> #56 | 16:17 |
mbuf | no difference, and hence no output | 16:17 |
mbuf | --> #57 | 16:17 |
mbuf | same as above; | 16:17 |
mbuf | --> #58 | 16:17 |
mbuf | --> #59 | 16:17 |
<-- mavu_ (n=mavu@59.178.189.159) has quit (Read error: 110 (Connection timed out)) | 16:17 | |
--> mavu_ (n=mavu@59.178.161.154) has joined #dgplug | 16:17 | |
mbuf | since we have added the file to the directory, but is not tracked (to index), git says you need to add it to the index; | 16:18 |
mbuf | --> #60 | 16:18 |
mbuf | make love doesn't work with Nayantaaara | 16:18 |
mbuf | --> #61 | 16:18 |
mbuf | since the object reference has already been removed from the index, we can simply remove the file; | 16:18 |
mbuf | --> #62 | 16:18 |
mbuf | --> #63 | 16:19 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:19 | |
mbuf | --> #64 | 16:19 |
mbuf | checking git status, just to check if our repo is clean; | 16:19 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:19 | |
mbuf | so this was a case where we added a file to the index, but, temporarily removed it from the index, because, we could make more changes; but, since we didn't want to make any change, we simply removed it; | 16:19 |
mbuf | --> #65 | 16:19 |
mbuf | we try a new letter for raaani-mukerji | 16:20 |
mbuf | --> #66 | 16:20 |
mbuf | we add it to the index; | 16:20 |
mbuf | --> #67 | 16:20 |
mbuf | But, she already rejected me. I forgot! So, we just rename the love letter so we can write a love letter to aishvarya-ray | 16:20 |
mbuf | you use 'git mv' for it; | 16:20 |
mbuf | yes, it works when you have added the file already to the index! | 16:21 |
mbuf | --> #68 | 16:21 |
mbuf | instead of git rm, you can use 'git reset HEAD file', in case, you feel that you might mistakenly use rm to remove a file | 16:21 |
mbuf | in this case, 'git reset HEAD file' does the same as 'git rm --cached file' | 16:21 |
mbuf | --> #69 | 16:22 |
mbuf | --> #70 | 16:22 |
mbuf | --> #71 | 16:22 |
mbuf | no differences, so no output; | 16:22 |
mbuf | --> #72 | 16:22 |
mbuf | --> #73 | 16:22 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 54 (Connection reset by peer)) | 16:22 | |
mbuf | since we add a file aishvarya-ray.txt, but, it has not been staged to the index and is thus untracked, git is saying there is an untracked file; | 16:23 |
mbuf | --> #74 | 16:23 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:23 | |
mbuf | Aishvarya Ray is married! I didn't know that until now :( | 16:23 |
mbuf | --> #75 | 16:23 |
mbuf | --> #76 | 16:23 |
mbuf | so I just remove the file; | 16:23 |
mbuf | --> #77 | 16:23 |
mbuf | --> #78 | 16:24 |
mbuf | --> #79 | 16:24 |
mbuf | our local repo is clean; | 16:24 |
mbuf | --> #80 | 16:24 |
mbuf | now, let us try to write a letter to pretty-zinta; | 16:24 |
mbuf | --> #81 | 16:24 |
sunny_slls | ! | 16:24 |
mbuf | I feel the letter is satisfactory, and I want to add it to the index; | 16:24 |
mbuf | --> #82 | 16:25 |
mbuf | I feel I can give this letter a shot at, and so I commit it to the local repo; | 16:25 |
mbuf | --> #83 | 16:25 |
mbuf | sunny_slls: shoot! | 16:25 |
sunny_slls | please explain the git reset head file since the file raani mukerjee was removed from the folder which it is rejected when created later? | 16:26 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:26 | |
sunny_slls | <eof> | 16:26 |
mbuf | sunny_slls: rejected is just a joke that I made; | 16:26 |
mbuf | sunny_slls: that is a use case scenario, where you have added a file to the index, and realized you mistakenly named it something else | 16:26 |
mbuf | sunny_slls: so if you want to rename it, you use 'git mv' | 16:27 |
mbuf | sunny_slls: git reset HEAD file, is like resetting the HEAD (part of git) | 16:27 |
mbuf | sunny_slls: which is the same pattern as 'git rm --cached' | 16:27 |
mbuf | sunny_slls: git has two pointers, HEAD and master; | 16:27 |
mbuf | sunny_slls: HEAD and master always point to the latest commit; | 16:28 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:28 | |
mbuf | sunny_slls: there are scenarios where they can point to different things; | 16:28 |
mbuf | sunny_slls: we'll come to that; | 16:28 |
mbuf | sunny_slls: <eof> | 16:28 |
<-- samar (n=samar-ad@115.108.6.29) has quit ("Ex-Chat") | 16:28 | |
mbuf | --> #84 | 16:28 |
mbuf | --> #85 | 16:28 |
mbuf | so, now you see that we have made a second commit, and that is shown first (on the top) | 16:29 |
mbuf | so every time you feel you are satisfied with your work, you make a commit; | 16:29 |
mbuf | --> #86 | 16:29 |
mbuf | HEAD is the current pointer or reference; HEAD^ points to the previous HEAD | 16:30 |
mbuf | so what 'reset --soft' does is rever the changes such that it keeps the changes in the index; | 16:30 |
mbuf | and because we used HEAD^, HEAD is shifted to the previous value that it had; | 16:31 |
mbuf | --> #87 | 16:31 |
mbuf | --> #88 | 16:31 |
mbuf | as you can see HEAD is now in the first commit; | 16:31 |
mbuf | --> #89 | 16:32 |
mbuf | --> 90 | 16:32 |
mbuf | 'reset --soft' keeps the changes in the index, and the files are retained in the working directory; | 16:32 |
mbuf | --> #91 | 16:32 |
hermes | ! | 16:32 |
mbuf | now, it is interesting to see the diff outputs; | 16:32 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:32 | |
<-- kishan (n=kishan@117.99.63.16) has quit (Remote closed the connection) | 16:32 | |
mbuf | hermes: shoot! | 16:32 |
hermes | why did we shift the head back to the first commit | 16:32 |
--> SkyRocknRoll (n=chatzill@122.164.52.232) has joined #dgplug | 16:33 | |
hermes | I mean what are we trying to achieve by doing that | 16:33 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:33 | |
hermes | eof | 16:33 |
mbuf | hermes: because we are undoing our last commit or the most recent one! | 16:33 |
mbuf | hermes: let's say you made a commit in a hurry, and you want to undo or redo it! | 16:33 |
hermes | alright, i get it | 16:33 |
hermes | eof | 16:33 |
mbuf | hermes: you rever the repository HEAD to the previous one, while the last changes you made are still in the working tree; | 16:33 |
mbuf | hermes: :) | 16:33 |
mbuf | *revert | 16:33 |
mbuf | --> #92 | 16:34 |
mbuf | --> #93 | 16:34 |
--> kishan (n=kishan@117.99.59.7) has joined #dgplug | 16:34 | |
mbuf | 'diff --cached' shows the difference clearly; | 16:34 |
mbuf | --> #94 | 16:34 |
mbuf | --> #95 | 16:34 |
mbuf | shows what will be committed if you did 'git commit -a -m message' | 16:34 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:34 | |
mbuf | --> #96 | 16:34 |
mbuf | --> #97 | 16:35 |
mbuf | good to check status, if you are not sure what the git repo state is in; | 16:35 |
mbuf | it says you have some changes in the index, to undo you can reset HEAD -- which will remove from index, but, still keep the files in the working directory; | 16:35 |
mbuf | --> #98 | 16:36 |
mbuf | --> #99 | 16:36 |
mbuf | --> #100 | 16:36 |
mbuf | or make some changes to satisfy pretty zinta | 16:36 |
mbuf | --> #101 | 16:36 |
mbuf | --> #102 | 16:36 |
mbuf | and we commit the message; | 16:36 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:36 | |
mbuf | note now the commit SHA1 message will be a new number; | 16:36 |
mbuf | earlier it was 661bc09... | 16:37 |
mbuf | --> #103 | 16:37 |
mbuf | --> #104 | 16:37 |
mbuf | now it is c66e7f1... | 16:37 |
--> Samsung (i=Samsung@115.108.6.29) has joined #dgplug | 16:37 | |
mbuf | --> #105 | 16:37 |
mbuf | now let's say I made a mistake in the commit message; I want to fix it | 16:38 |
mbuf | --> #106 | 16:38 |
mbuf | --> #107 | 16:38 |
mbuf | you use 'git commit --amend' | 16:38 |
mbuf | --> #108 | 16:38 |
mbuf | --> #109 | 16:38 |
mbuf | again note the new SHA-1 value; | 16:38 |
mbuf | --> #110 | 16:38 |
mbuf | --> #111 | 16:38 |
mbuf | just checking for status; | 16:38 |
mbuf | --> #112 | 16:39 |
mbuf | now I am making some more changes in pretty-zinta.txt | 16:39 |
mbuf | --> #113 | 16:39 |
mbuf | because, there were some changes in pretty-zinta.txt in the index before and now in the working directory, git diff shows the changes; | 16:39 |
mbuf | --> #114 | 16:40 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:40 | |
mbuf | nothing is added to index, so no change in the output; | 16:40 |
mbuf | --> #115 | 16:40 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:40 | |
mbuf | --> #116 | 16:40 |
mbuf | because, we have added some changes to the working directory, and pretty-zinta.txt is already tracked in the repo, 'diff HEAD' shows the changes; | 16:40 |
mbuf | --> #117 | 16:40 |
mbuf | But, I couldn't find Pretty Zinta to give the love letter; how sad! | 16:41 |
mbuf | --> #118 | 16:41 |
mbuf | --> #119 | 16:41 |
mbuf | now we totally remove the committed entry in the repo _and_ in the working tree using 'reset --hard' | 16:41 |
mbuf | --> #120 | 16:41 |
mbuf | --> #121 | 16:41 |
mbuf | --> #122 | 16:41 |
mbuf | --> #123 | 16:42 |
mbuf | --> #124 | 16:42 |
mbuf | so, this was a use case, where you completely undo a previous commit from the local repo, and also the changes from your working directory; | 16:42 |
mbuf | this is something that you will probably use often, if you don't want to keep whatever changes you have made; | 16:42 |
mbuf | --> #125 | 16:42 |
mbuf | --> #126 | 16:43 |
mbuf | --> #127 | 16:43 |
mbuf | --> #128 | 16:43 |
mbuf | --> #129 | 16:43 |
mbuf | --> #130 | 16:43 |
mbuf | these are examples of using 'grep' command with git; | 16:43 |
mbuf | these will search source files as well as git objects (called as blobs) | 16:43 |
mbuf | for any search pattern that you specify; | 16:43 |
mbuf | --> #131 | 16:43 |
mbuf | --> #132 | 16:44 |
mbuf | --> #133 | 16:44 |
mbuf | --> #134 | 16:44 |
mbuf | --> #135 | 16:44 |
mbuf | --> #136 | 16:44 |
mbuf | --> #137 | 16:44 |
mbuf | there are different ways to see previous commit and log messages; | 16:44 |
mbuf | these are few examples; | 16:44 |
mbuf | --> #138 | 16:45 |
mbuf | --> #139 | 16:45 |
mbuf | --> #140 | 16:45 |
mbuf | --> #141 | 16:45 |
mbuf | --> #142 | 16:45 |
mbuf | git show also produces nice output; I can't show everything on a slide though; | 16:45 |
mbuf | when you practice after the session, you can play with these :) | 16:45 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:45 | |
mbuf | --> #143 | 16:45 |
mbuf | sometimes you are working on a change, and you suddenly have something more important to try; but, you don't want to discard the changes you have made; | 16:46 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:46 | |
mbuf | so you simply 'stash' it, or leave it aside; | 16:46 |
mbuf | to do that you use 'git stash' | 16:46 |
<-- Shrink (n=sgupta@redhat/shrink) has quit (Read error: 113 (No route to host)) | 16:46 | |
mbuf | --> #144 | 16:46 |
mbuf | even this has an identifier; | 16:46 |
mbuf | --> #145 | 16:46 |
mbuf | --> #146 | 16:46 |
mbuf | --> 147 | 16:47 |
mbuf | whatever changes you make are local and not affected by your stashed changes; | 16:47 |
mbuf | once you are done and you want to reapply the work that you left aside, you can just apply it back using 'git stash apply' | 16:47 |
mbuf | --> #148 | 16:47 |
mbuf | --> #149 | 16:47 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:47 | |
mbuf | --> #150 | 16:47 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:48 | |
mbuf | It says I have modified the file, to-my-dearest.txt, so I need to add it before committing; I just use 'commit -a -m' to do it in one shot; | 16:48 |
mbuf | --> #151 | 16:48 |
mbuf | tagging is important if you want a label for a particular commit; | 16:48 |
mbuf | --> #152 | 16:48 |
mbuf | --> #153 | 16:49 |
mbuf | --> #154 | 16:49 |
mbuf | just 'git tag' will list the tags | 16:49 |
mbuf | --> #155 | 16:49 |
mbuf | --> #156 | 16:49 |
mbuf | --> #157 | 16:49 |
mbuf | Remove the tag using 'tag -d' | 16:49 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 16:49 | |
mbuf | --> #158 | 16:50 |
mbuf | --> #159 | 16:50 |
--> yevlempy (n=yevlempy@124.124.157.94) has joined #dgplug | 16:50 | |
mbuf | if you want your friend to use a particular tag release of your code, you can refer the same | 16:50 |
mbuf | and hence, one can use it for references; | 16:50 |
mbuf | --> #160 | 16:50 |
hermes | !\ | 16:50 |
mbuf | sometimes, when you are working with huge projects, and you are new developer | 16:50 |
mbuf | they might only accept patches, so you can use the git-format-patch command to get the change you made and send it via e-mail | 16:51 |
mbuf | hermes: shoot! | 16:51 |
mbuf | --> #161 | 16:51 |
mbuf | --> #162 | 16:51 |
mbuf | --> #163 | 16:51 |
mbuf | --> #164 | 16:51 |
mbuf | these show how a git patch looks like; | 16:51 |
hermes | what if i want to add a tag to some other identifier | 16:51 |
--> akuscifi007 (n=akuscifi@122.162.82.58) has joined #dgplug | 16:52 | |
hermes | not to what head is currently pointing | 16:52 |
hermes | eof | 16:52 |
mbuf | hermes: git has lot of command options; and each command has lot of options which are described in detail with examples in their manual page; | 16:53 |
mbuf | hermes: sure you can; check this (later) http://www.kernel.org/pub/software/scm/git/docs/git-tag.html | 16:53 |
mbuf | hermes: eof | 16:53 |
mbuf | --> #165 | 16:53 |
hermes | mbuf :ok, thankful | 16:53 |
hermes | eof | 16:53 |
mbuf | reflog contains list of all your previous commits; | 16:54 |
mbuf | --> #166 | 16:54 |
mbuf | so you can actually go back to some commit that you made; | 16:54 |
mbuf | *made directly; | 16:54 |
mbuf | --> #167 | 16:54 |
mbuf | here we resetting it to 1, i.e., where HEAD was at {1] | 16:55 |
mbuf | remember again, that reset --hard, will revert and also remove the changes in the working directory; | 16:55 |
mbuf | --> #168 | 16:55 |
mbuf | --> #169 | 16:55 |
mbuf | --> #170 | 16:55 |
mbuf | so we have undone all our previous changes, except our first commit; | 16:56 |
mbuf | --> #171 | 16:56 |
mbuf | git basically doesn't track files, it only tracks content; | 16:56 |
mbuf | so ideally, we shouldn't be creating a separate love letter for each of our dear ones; | 16:57 |
mbuf | what if we had one love-letter, and the change control tracker, keeps track of the changes w.r.t. each dear one; | 16:57 |
mbuf | so in index, and repo, only objects, or the changes are stored, and not another copy of the file; | 16:58 |
mbuf | so far we have been working in the default branch, called the 'master' branch | 16:58 |
mbuf | --> #172 | 16:58 |
sunny_slls | ? | 16:58 |
mbuf | I only have to-my-dearest.txt file in the working directory; | 16:58 |
mbuf | sunny_slls: shoot! | 16:58 |
sunny_slls | sorry typing mistake | 16:58 |
mbuf | sunny_slls: no problem; | 16:59 |
mbuf | --> #173 | 16:59 |
mbuf | so, I am going to try my luck with Priyaaanka-chopra | 16:59 |
mbuf | I create a new branch for it; | 16:59 |
mbuf | --> #174 | 16:59 |
mbuf | --> #175 | 16:59 |
mbuf | so you now see two branches; the asterisk (*) shows which branch I am currently working in; | 16:59 |
mbuf | --> #176 | 16:59 |
mbuf | --> #177 | 17:00 |
mbuf | 'branch -d' is what I use to delete a branch; | 17:00 |
mbuf | branching is completely handled by git, you will only see one file in the working directory; | 17:00 |
mbuf | but, as you switch branch, the respective changes in the file for that particular branch will prevail, when you open the file; | 17:01 |
mbuf | we'll see this next; | 17:01 |
mbuf | --> #178 | 17:01 |
mbuf | 'checkout -b' is used to create a new branch and to enter into it; | 17:01 |
mbuf | --> #179 | 17:01 |
mbuf | --> #180 | 17:01 |
mbuf | --> #181 | 17:01 |
mbuf | it now shows we are in the priyaaanka-chopra branch; | 17:02 |
mbuf | --> #182 | 17:02 |
mbuf | --> #183 | 17:02 |
mbuf | to go back, we again use 'checkout' | 17:02 |
mbuf | --> #184 | 17:02 |
mbuf | --> #185 | 17:02 |
mbuf | so, 'git branch' shows us we are now in the 'master' branch; | 17:02 |
mbuf | --> #186 | 17:02 |
<-- akuscifi007 (n=akuscifi@122.162.82.58) has quit (Read error: 104 (Connection reset by peer)) | 17:02 | |
mbuf | I am now in the priyaaanka-chopra branch; | 17:03 |
mbuf | --> #187 | 17:03 |
mbuf | --> #188 | 17:03 |
mbuf | I am making some changes to to-my-dearest.txt and I am committing it; | 17:03 |
mbuf | --> #189 | 17:03 |
mbuf | --> #190 | 17:03 |
mbuf | --> #191 | 17:03 |
mbuf | so, now you see that we have HEAD and priyaaanka-chopra ; | 17:04 |
mbuf | our commit (latest) is a63ae26... | 17:04 |
mbuf | there is only one file in the working directory; | 17:04 |
mbuf | if I switch to the master branch, there will be HEAD and master for the master branch with only 958d5ac... | 17:04 |
mbuf | --> #192 | 17:04 |
mbuf | --> #193 | 17:04 |
mbuf | --> #194 | 17:04 |
mbuf | Now, I feel that priyaaanka-chopra changes are very good, and I can use it in 'master' copy | 17:05 |
mbuf | so I simply merge the changes from the priyaaanka-chopra branch to the master copy; | 17:05 |
mbuf | --> #195 | 17:05 |
mbuf | --> #196 | 17:05 |
mbuf | --> #197 | 17:05 |
mbuf | so now we have the latest commit message on the master branch; | 17:06 |
mbuf | this use case is to show that if you decide to work on a bug or a new feature in your code, you always make a copy of it in the branch | 17:06 |
mbuf | you work in the branch, test it, and if satisfactory you merge it back to the master copy | 17:06 |
hermes | ! | 17:06 |
mbuf | if you are not satisfied with the branch, you can always delete it! | 17:06 |
mbuf | this is very important, unlike, newbies hacking on the same code, again, and again, and again, without being able to revert changes quickly and correctly; | 17:07 |
mbuf | hermes: shoot! | 17:07 |
hermes | mbuf : Added very sweet is the name given to the commit operation right? It had nothing to do with the changes that we actually make to out txt file | 17:07 |
hermes | right | 17:07 |
hermes | ? | 17:08 |
hermes | eof | 17:08 |
hermes | Sorry our text file | 17:08 |
hermes | ef | 17:08 |
mbuf | hermes: that is correct! it is the commit message like, 'git commit -a -m 'Added very sweet'' | 17:08 |
hermes | eof | 17:08 |
--> kopecks89 (n=koyel@117.201.96.138) has joined #dgplug | 17:09 | |
mbuf | hermes: as I told earlier, this is not about what you write in the love letter; it is only about managing love letters :) | 17:09 |
mbuf | hermes: eof | 17:09 |
sunny_slls | ! | 17:09 |
mbuf | sunny_slls: shoot! | 17:09 |
sunny_slls | suppose there are many other branches and we wan't to merge some of them then how can we do that | 17:10 |
mbuf | there has been no conflict here; but, git tries to do its best to merge things; if there is a conflict, you need to resolve it manually, add the file again to index and commit it to the repo; | 17:10 |
sunny_slls | in the master? | 17:10 |
mbuf | sunny_slls: merge one by one; | 17:10 |
mbuf | sunny_slls: git merge foo; git merge bar; git merge alpha; git merge beta; | 17:10 |
sunny_slls | thanks | 17:11 |
sunny_slls | eof | 17:11 |
mbuf | sunny_slls: I am only describing the basic work mechanism of git; it doesn't define how your project workflow should be; that is something that your team must decide; | 17:11 |
mbuf | --> #198 | 17:11 |
mbuf | usually, you will get the source code from upstream (like from sourceforge.net, or freshmeat.net) and you will work on your local copy; | 17:11 |
mbuf | so, here, I am simply simulating an upstream update, by manually doing a commit in the master branch -- as if it came from the upstream project; | 17:12 |
mbuf | --> #199 | 17:12 |
mbuf | --> #200 | 17:12 |
mbuf | note the commits in the master, the latest one being 19e0205... | 17:12 |
mbuf | --> #201 | 17:12 |
mbuf | --> #202 | 17:12 |
mbuf | --> #203 | 17:13 |
mbuf | --> #204 | 17:13 |
mbuf | --> #205 | 17:13 |
mbuf | Now, I am checking out priyaaanka-chopra branch; | 17:13 |
mbuf | --> #206 | 17:13 |
mbuf | --> #207 | 17:13 |
mbuf | --> #208 | 17:13 |
mbuf | --> #209 | 17:13 |
mbuf | --> #210 | 17:13 |
mbuf | you see the different commit history between the master and the priyaaanka-chopra branch; | 17:13 |
mbuf | the master branch has had one commit more than the priyaaanka-chopra branch; | 17:14 |
mbuf | --> #211 | 17:14 |
mbuf | Now I am making some changes to priyaaanka-chopra branch; | 17:14 |
mbuf | --> #212 | 17:14 |
mbuf | --> #213 | 17:14 |
mbuf | Note the new commit is 1d1fd9f... which is different from the master (19e0205...) | 17:15 |
mbuf | --> #214 | 17:15 |
mbuf | Now I could merge the changes (upstream) on the master with the priyaaanka-chopra branch changes; | 17:15 |
mbuf | but, we have what is called as 'rebase' which basically overwrites our previous changes and merges the changes in the priyaaanka-chopra branch, as we do it next; | 17:16 |
mbuf | --> #215 | 17:16 |
mbuf | because of conflict, 'rebase' failed; | 17:16 |
mbuf | --> #216 | 17:16 |
mbuf | so that is the conflict in the to-my-dearest.txt between the master and the priyaaanka-chopra branch; we edit it to choose either one above or below the ====== | 17:17 |
mbuf | Remove the <<<<, >>>> lines; | 17:17 |
mbuf | --> #217 | 17:17 |
mbuf | --> #218 | 17:17 |
mbuf | --> #219 | 17:18 |
mbuf | --> #220 | 17:18 |
mbuf | Just checking git gl and since the file has been modified, we need to add it to index before committing; | 17:18 |
mbuf | --> #221 | 17:18 |
mbuf | since we have fixed the conflict, we can ask 'git rebase' to skip the conflict and proceed to merge; | 17:18 |
mbuf | --> #222 | 17:18 |
mbuf | --> #223 | 17:19 |
mbuf | --> #224 | 17:19 |
mbuf | master changes have been merged to priyaaanka-chopra branch | 17:19 |
mbuf | --> #225 | 17:19 |
mbuf | But, most importantly note that it has overwritten our previous commit log; | 17:19 |
mbuf | Sometimes when we are working in our branch copy, we will make many commits; | 17:19 |
mbuf | When we want to synchronize our code base with an upstream project, we fetch the code from the upstream project repository; | 17:20 |
mbuf | and we need to merge it with our local copy; | 17:20 |
mbuf | so, we may not want to keep a history of our local changes; simply merge it with our changes, as long as our changes are there in code; | 17:20 |
mbuf | so rebase basically rewrites history! | 17:20 |
mbuf | --> #226 | 17:21 |
mbuf | --> #227 | 17:21 |
mbuf | so we have covered most use cases; to get a copy of a project repository in a server, you basically 'clone' a copy of the repository; | 17:21 |
mbuf | so you get the complete history; | 17:21 |
mbuf | --> #228 | 17:21 |
mbuf | --> #229 | 17:21 |
mbuf | If you already have cloned a repo, and you only want to get the upstream changes, just use fetch | 17:22 |
mbuf | --> #230 | 17:22 |
mbuf | fetch will only download the upstream changes to the local system; it will not merge it with the master code; | 17:22 |
mbuf | pull will fetch+merge | 17:22 |
mbuf | --> #231 | 17:22 |
mbuf | git provides different ways to download code from remote repos; | 17:23 |
mbuf | --> #232 | 17:23 |
mbuf | --> #233 | 17:23 |
mbuf | --> #234 | 17:23 |
mbuf | --> #235 | 17:23 |
mbuf | git remote shows that the remote repo also has a 'origin' | 17:23 |
mbuf | is a reference link | 17:23 |
mbuf | --> #236 | 17:23 |
mbuf | --> #237 | 17:23 |
mbuf | --> #238 | 17:23 |
<-- kopecks (n=koyel@117.201.100.101) has quit (Read error: 110 (Connection timed out)) | 17:23 | |
mbuf | branch only shows local branches; git branch -r shows remote branches | 17:24 |
mbuf | --> #239 | 17:24 |
mbuf | so in the remote repo also, we have a origin/HEAD and origin/master | 17:24 |
mbuf | --> #240 | 17:24 |
mbuf | you can add remote repository instance to your local .git/ to get updates; | 17:24 |
mbuf | you will learn these as you work between local and remote repos; | 17:25 |
mbuf | this ends the presentation; | 17:25 |
mbuf | I know I haven't covered many use cases, but, I feel these are basic ones that should help you get started with using git; | 17:25 |
mbuf | gitorious.org provides nice git commands on doing fetches, updates, and merges, which I like; | 17:25 |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!