Skip to content

Instantly share code, notes, and snippets.

@kingluddite
Created April 26, 2024 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingluddite/ba63926c9bda95eb78bc13ed7e67a174 to your computer and use it in GitHub Desktop.
Save kingluddite/ba63926c9bda95eb78bc13ed7e67a174 to your computer and use it in GitHub Desktop.
Simple step by step instructions for working with Git and GitHub

Certainly! Here's a step-by-step guide on setting up a GitHub repository, cloning it to your computer, and updating files locally:

Setting up a GitHub Repository:

  1. Create a GitHub Account: If you don't already have one, go to GitHub and sign up for a free account.

  2. Create a New Repository:

    • Click on the "+" icon in the top-right corner of the GitHub interface and select "New repository."
    • Give your repository a name, add an optional description, choose whether it should be public or private, and initialize it with a README file if desired.
    • Click on the "Create repository" button.

Cloning the Repository to Your Computer:

  1. Open Git Bash: If you haven't already installed Git Bash, you can download it from here and follow the installation instructions.

  2. Clone the Repository:

    • In Git Bash, navigate to the directory where you want to clone the repository using the cd command. For example:
      cd Documents
      
    • Copy the clone URL of your GitHub repository from the repository's page.
    • In Git Bash, use the git clone command followed by the repository URL. For example:
      git clone https://github.com/your-username/your-repository.git
      
    • Press Enter. Git will clone the repository to your local machine.

Updating Files Locally:

  1. Navigate to the Repository Directory:

    • Use the cd command to navigate into the directory of the cloned repository. For example:
      cd your-repository
      
  2. Make Changes to Files:

    • Use your preferred text editor or IDE to make changes to the files within the repository. You can add new files, edit existing ones, or delete files as needed.
  3. Add and Commit Changes:

    • Use the git status command to see the current status of your repository and identify the changes you've made.
    • Use the git add command to stage the changes you want to commit. For example, to stage all changes, you can use:
      git add .
      
    • Use the git commit command to commit the staged changes along with a descriptive commit message. For example:
      git commit -m "Updated README.md with project information"
      
  4. Push Changes to GitHub:

    • Use the git push command to push your committed changes to the GitHub repository. For example:
      git push origin main
      
    • Replace main with the name of your branch if it's different from the default branch.

That's it! You've now set up a GitHub repository, cloned it to your computer, made changes to files locally, and pushed those changes back to GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment