Skip to content

Google-Cloud-Tech-Career-Training/week1-git-story

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup

Local environment setup

Windows only: On Windows, you will need to run these commands from git bash (Git Bash download).

  1. Link your github to your local environment
    See: Connecting to GitHub with SSH

    Or complete these steps in order:


  2. Add your git email and username to your local environment

    • $ git config --global user.email "[email protected]"
    • $ git config --global user.name "Your Name"

Clone this repository

  • Locate and click on the green CODE button in the top right of this page
  • Select SSH
  • Copy the url
  • In your terminal, cd into the location where you would like this repo to live. The next command will create a folder containing this repo's files.
  • Type the following command :
    git clone <url> (replace <url> with the url)

git_screenshot_code_link

Exercise

In this exercise you will learn about:

  • Branches
  • Staging and committing
  • Pushing to remote
  • Creating a Pull Request

  1. Create a branch off the main branch

    By creating a branch, you're making a copy of the branch that you're currently on (i.e. main), and giving a name to this copy (your branch name). Changes to your branch will not affect the source branch.

    Command: git checkout -b <name-of-your-branch> (replace <name-of-your-branch> with the name of your branch)


  1. Assign a value to every variable in the file words.py

    e.g.: name1 = "Lenz"


  1. Stage your changes, preparing for the commit

    When you make changes to files you must stage them before committing them. Only staged changes will be saved when you commit. If you don't want to save the changes to a specific file for example, you could avoid staging that file. In your next commit, those changes will not be included.

    Command: git add .

    The . here represents "the current folder", or in other words "all files in the current folder". You could also stage a single file like this: git add words.py .


  2. Commit your staged changes and write a short descriptive message about your changes.

    The commit command captures a snapshot of the project's currently staged changes. You can always roll back to this commit later, no matter what other changes you've made.

    Command: git commit -m "<short description of changes>"


  3. Push your locally committed changes to github.com

    The push command uploads all your current commits to your github repository.

    Command: git push

    ⚠️ The first time you run git push on a newly created branch, it does not yet exist on github. You will get an error message showing you the command to run to create this branch on github.com. It should look something like this: git push --set-upstream origin <name-of-your-branch>


  1. Create a Pull Request on github

    By opening a Pull Request you are requesting to merge the changes on your branch into another branch (the base branch). You can think of it as making your "copy" the main version.

    1. In the Pull Requests menu, create a new Pull Request




    1. Select main as the base branch and your branch as the branch to compare to. Then hit Create Pull Request




    1. Give your PR a title (use your name for this exercise), and hit Create Pull Request




Additional resources

Releases

No releases published

Packages

No packages published

Languages