# Github Authentication This is just for github cli. ## Step 1 Setup 1. Go to [github cli](https://cli.github.com/) 2. `brew install gh` or download it. 3. Get the version of github cli to ensure you installed. ```bash gh --version ``` 4. Login with your account (follow instruction and login with web redirect) ```bash gh auth login ``` 5. Make sure you are login in. ```bash gh auth status ``` 6. **The most important part** ```bash gh auth setup-git ``` ## Step 2 Create repository By different situations you can choose different way to create remote repository. ### Create from cli 1. Use cli create command and follow the instruction ```bash gh repo create ``` ![image alt](https://share.cleanshot.com/kv0zrqVY/download) 2. Edit files 3. Add the modified file into staged status, which means is the file that may going to commit (. means all) ```bash git add [file name] or [.] ``` 4. You finish your feature or bug fixing then commit ```bash git commit -m "I do fix a bug and how" ``` 5. Push it to remote repository of github ```bash git push origin main ^^^^^^ (remote name) git push origin main ^^^^ (branch name) ``` 6. If there is not red lines, you are success ### Create from website 1. Go to github website and create new repository ![image](https://share.cleanshot.com/xnRJYTsh/download) 2. Clone it to local ```bash gh repo clone [project name] ``` 3. Do the same as **Create from cli** ### Create from existing project 1. Go to github website and create new repository 2. Go to the project and init git ```bash git init ``` 3. Add `.gitignore` file to ignore unwanted file from version control 4. Add remote repository http url to let it know where to push. (`origin` is a name for that remote url, it can be any name) ```bash git remote add origin https://github.com/github2138/temp-project3.git ``` 5. Do the same as **Create from cli** ## Use VSCode to do `git add`, `git commit`, `git push` But **Step 1** needs to be done first!!! 1. Stage your modified code => `git add`, follow the image there is no command need to do. ![image alt](https://share.cleanshot.com/dR5kxNdb/download) 2. Commit the code => `git commit` ![image alt](https://share.cleanshot.com/JkDh9TqC/download) 3. Push your to remote => `git push` ![image alt](https://share.cleanshot.com/7kl2C1Y5/download) ## Switch Branches ![image alt](https://share.cleanshot.com/Gfz6XYrQ/download) ## Car Violation Project Flow ### Step 1 project setup 1. Create new repository over github website and get the url and copy it. 2. Clone my project into your local develop folder. You can change name at the end of the command below. ```bash= git clone https://github.com/work-weicheng/ben-backend.git [project_name] ``` 3. Change origin remote to your repository ```bash= git remote set-url origin [new repository url] ``` 4. Push it to your github ```bash= git push origin main ``` ### Step 2 Open Collaorator for me - My github email: weicheng2138@gmail.com ![image alt](https://share.cleanshot.com/62sbwVcG/download) ### Step 3 Work Flow 1. Develop your application 2. When your complete some of the function, commit it and push it. 3. whenever you push it to github, notify me.