# Suggestions, knowledge, and advice Today was our first lecture and we covered a lot of "cognitive ground". I wanted to highlight a few of the key points Carl covered: ## Homework will be submitted via GitHub You must submit your homework to GitHub by the designated due date and time. You must add the course TA and instructors as contributors to your GitHub repository. This allows access to your homework. - Colton's GitHub handle is `ccbaumler`. - Dr. Reynolds is `plnreynolds`. - Dr. Stahmer is `cstahmer`. If you cannot submit to GitHub, for this homework you may upload your R file to Canvas, but you will lose a full letter grade. These are the submission instructions! -> https://canvas.ucdavis.edu/courses/995571/pages/assignment-submission-instructions After you make a new directory following the naming convention for your homeworks, connect your local git repository to a github repository with the `git remote add` Click `Create Repository` ![image](https://hackmd.io/_uploads/B1I_f7yPkl.png) Copy the `SSH` link ![image](https://hackmd.io/_uploads/rJfTfQkPkx.png) Navigate to your local `sts115_yourname` directory: ``` cd ~/sts115_yourname ``` Add the `SSH` link of your GitHub Repository to your local git directory. ``` git remote add origin git@github.com:ccbaumler/sts115_coltonbaumler.git ``` Check that your local git directory is linked to your github repo. ``` git remote -v origin git@github.com:ccbaumler/sts115_coltonbaumler.git (fetch) origin git@github.com:ccbaumler/sts115_coltonbaumler.git (push) ``` ## Please add a photo and bio to Canvas Please update your canvas account to include a photo and bio. Thanks! ## Always have the reader pulled up during class Here is the link to the reader - https://ucdavisdatalab.github.io/adventures_in_data_science/ Here is the link to the install guides - https://ucdavisdatalab.github.io/install_guides/ ## Treat coding like a logic puzzle or game Think of coding as a logic game. Computers and code were built and written by people. The maintainers of code languages do their best to write them in a standardized and logical format for easier use. Therefore, treat coding like a logic puzzle. The best part about this logic puzzle is that you can have endless attempts to run commands as long as you do not modify or delete the original files. ## Take breaks when you get stuck Taking breaks is a good thing in knowledge work. Try to pace yourself by starting the homeworks early and taking breaks to think about the logic! (Or allow you mind to rest and come back to the problem with fresh eyes!) ## What is a command, keyword argument, and positional argument? Some jargon for the command line. A ***command*** is a program that is executable. For example, the `ls` command is a program that lists the files and directories within a directory. ``` $ ls directory hello.txt ``` We can add ***keyword arguments*** (options or flags) to a command to change its functionality. These are explicit arguments that have a pre-defined modification to a command. Consider adding `-la` keyword arguments to our `ls` command and how that changes the output. ``` $ ls -la total 95 drwxrwsr-x 3 baumlerc baumlerc 4 Jan 10 13:18 . drwxrwsr-x 64 baumlerc baumlerc 87 Jan 10 13:18 .. drwxrwsr-x 2 baumlerc baumlerc 3 Jan 10 13:22 directory -rw-rw-r-- 1 baumlerc baumlerc 0 Jan 10 13:18 hello.txt ``` These arguments may be added in various positions across the command. `ls -l -a` or `ls -a -l` or `ls -la` or `ls -al` An additional argument type is the ***positional argument***. This requires a specific positional like `mv <filename> <newfilelocation>`. This may be combined with ***keyword arguments***! ``` $ mv --verbose hello.txt directory/ renamed 'hello.txt' -> 'directory/hello.txt' ``` ``` $ ls directory/ hello-again.txt hello.txt ``` Always ask for `--help`. While the `man` command may return information on a commands functionality, you can also use the `--help` keyword argument. :::info Add the `--help` keyword argument to see the arguments available to a command ::: ## Git and GitHub configuration During the class today, we spent time configuring `git`. What did the following commands do? ``` git config --global user.email "youremail@email.com" ``` ``` git config --global user.name "yourname" ``` These commands are adjusting the configuration of the git software by modifying a ***dotfile***, `.gitconfig`. You can see the contents of the file by copying the following command: ``` cat ~/.gitconfig ``` The output should be something like: ``` [user] email = ccbaumler@ucdavis.edu name = ccbaumler ``` If your branch name is `master` after running `git init`, you will need to change the branch to `main`. To configure the dotfile to always create a main branch: ``` git config --global init.defaultBranch main ``` Run the `cat` command from above to see what this command `git config` command did: ``` cat ~/.gitconfig ``` The output: ``` [user] email = ccbaumler@ucdavis.edu name = ccbaumler [init] defaultBranch = main ``` If you need to change an existing local branch from `master` to `main`: - rename your local branch from master to main: `git branch -m master main` - push to main: `git push -u origin main` - update your default branch on GitHub side: ![F5S1A](https://hackmd.io/_uploads/BJ52Kz1PJe.gif) - Then delete the remote master branch: `git push origin --delete master` Reference: https://stackoverflow.com/questions/67543278/git-how-to-change-default-branch-for-everything-i-do ## No error message doesn't always mean it worked! What is the difference between: ``` git config --global user.email "youremail@email.com" ``` ``` git config --global email.address "youremail@email.com" ``` One of these commands works by configuring the `.gitconfig` file. The other command does not do anything ***and*** does not return any error message. It just does not work. This is a **hidden error** in the `git config` command. Some programmers would consider lacking explicit error messages to be a bug in hte code because of the downstream errors this causes.