# First git project ## 1. configuring name, email and editor git config --global user.name "John Doe" git config --global user.email "johndoe@example.com" # Note: if using VSCode, the "--wait" option # allows git to understand when you are finished # editing a text file git config --global core.editor "code --wait" # If you see the message: # Aborting commit due to empty commit message. # when doing 'git commit', look up online how to use your # editor together with git. ## 2. creating a directory mkdir test_project ## 3. creating a git repository cd test_project/ git init ## 4. creating main.c and Makefile # The normal/easy way is to create new files in a text editor, # copy/paste their content from the question, then save them in the # appropriate directory (test_project/main.c, test_project/Makefile) # Make sure that your editor uses actual TAB characters in the Makefile # This can be verified with 'hexdump -C Makefile': the TAB character # have ASCII code 9 # If you prefer to do it from the terminal, you could use this command to create it: printf '#include \n\n\nint main()\n{\n\tprintf("Hello, world!\\n");\n\treturn 0;\n}\n' > main.c printf 'main: main.o\n\tclang -Wall -O3 -o $(@) $(^)\n\nmain.o: main.c\n\tclang -Wall -O3 -c -o $(@) $(<)\n' > Makefile ## 5. build the executable main and create .gitignore make # Preferably, we create a file containing the following lines: # *.o # /main # and save it as test_project/.gitignore # Alternatively, printf '*.o\n/main\n' > .gitignore ## 6. Stage git add -A git status ## 7. Commit git commit -m 'First commit of test_project.' ## Second git project ## 1. Clone Alice's repository git clone https://www.poirrier.ca/courses/softeng/ex/alice.git cd alice/ ## 2. Fetch and checkout Bob's commit git fetch https://www.poirrier.ca/courses/softeng/ex/bob.git git log # does not show Bob's commit git log --all # still does not show Bob's commit git checkout 5ef767 # or equivalently, git checkout FETCH_HEAD git log # now Bob's commit appears ## 3. Fetch and checkout Carol's branch # Fetch Carol's repository git fetch https://www.poirrier.ca/courses/softeng/ex/carol.git git log # nothing from Carol appears git branch # carol_branch does not appear # Fetch Carol's repository, and also the branch "carol_branch". # Call it the same locally. git fetch https://www.poirrier.ca/courses/softeng/ex/carol.git carol_branch:carol_branch git branch # carol_branch now appears git checkout carol_branch git log --all --graph # 4. Implement the modification # Add modify the preprocess() method to look like: # def preprocess(self): # self.clauses.sort(key=lambda clause: len(clause[0]) + len(clause[1])) git diff # observe what you changed git add -A # stage your change git diff --staged # observe what is staged (what you are about to commit) git commit -m "Performance improvement: Sort the clauses by number of literals." # 5. Fetch Dan's branch git fetch https://www.poirrier.ca/courses/softeng/ex/dan.git dan_branch:dan_branch git branch # list branches git checkout dan_branch git log --all --graph # 6. Rebase our modifications (on our local carol_branch) on top of dan_branch git checkout carol_branch git rebase dan_branch # Note, if the rebase was trivial, then you are done # If there was a conflict, you need to resolve it (in truthtable.py), # then mark the conflict as resolved: git add truthtable.py git rebase --continue # 7. Fetch Eve's branch git fetch https://www.poirrier.ca/courses/softeng/ex/eve.git eve_branch:eve_branch git checkout eve_branch # Look at Eve's code git checkout carol_branch git merge eve_branch # This merge has conflicts, fix them in truthtable.py, then git add -A git commit git log --all --graph