TIL

Web Dev Bootcamp TIL Day-5(Git and Conda)

frannyk 2022. 4. 25. 08:50

Setting Git Connection

 

git config --global user.name "KimmyJay"

git confit --global user.email "fkim0801@gmail.com"

- login

 

git init

- creates empty git repository

 

git add ...

- ex) git add style.css

- gid add. adds all files

 

git status

- lets you see which changes have been staged / which files aren't being tracked by Git

 

git commit -m "first commit"

- creates history of commits

- name does not necessarily need to be "first commit"

 

git remote add origin https://github.com/KimmyJay/projectname.git 

- establishing connection w/ github repository

 

git remote -v

- checks if connection has been established

 

git push origin "branch name"

- ex) git push origin main

 


Git commands for team work

 

git clone git@github.com: https://github.com/KimmyJay/projectname.git foldername

- Clones a file from github repository and stores it in designated folder name

 

git checkout -b branchname

- Creates separate branch so that your commitments does not impact final product

 

git add .

git commit -m "first commit"

git push origin branchname

 

git pull origin main

- git pull origin master will pull changes from the origin remote, main branch and merge them to the local checked-out branch.

 

git checkout branchname

- Changes branch

 


Conda for venv and packages

conda create --name myenv

- creates new virtual enviornment named myenv

 

conda activate myenv

- activates virtual enviornment

 

conda install packagename

 

conda list

- displays installed packages 

 


Python Basics

List Comprehension

  • newlist = [expression for item in iterable if condition == True]
  • ex) newlist = [x for x in fruits if x != "apple"]
  • ex) weapons = [ [w[0], w[1] - weapon_speed] for w in weapons if w[1] > 0]

Scope and Nested Functions

  • inner functions are able to access outer function variables, but outer functions are not able to access inner function variables. Here is what that looks like in code:

def outer_func():

    location = "Inside the outer function!"

 

    def inner_func():

        location = "Inside the inner function!"

        print(location)

 

inner_func()

 

print(location)

outer_func()

 

Here is what the output looks like:

Inside the inner function!

Inside the outer function!