Git Commands Basics
16 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which command creates a copy of a repository from GitHub to your local machine?

  • `git fork`
  • `git init`
  • `git clone` (correct)
  • `git pull origin master`
  • What does git add . do in a Git repository?

  • Adds all modified and new files to the staging area (correct)
  • Commits all changes with a default message
  • Resets the repository to a previous commit
  • Removes files from the staging area
  • How do you create a new branch named feature-branch in Git?

  • `git create feature-branch`
  • `git branch feature-branch` (correct)
  • `git new-branch feature-branch`
  • `git branch -c feature-branch`
  • To switch to a branch named development, which command should you use?

    <p><code>git checkout development</code></p> Signup and view all the answers

    What command would you use to remove the last commit while keeping its changes in the working directory?

    <p><code>git reset --soft HEAD^</code></p> Signup and view all the answers

    If you want to see all the commits made in a Git repository, which command should you use?

    <p><code>git log</code></p> Signup and view all the answers

    How do you create and switch to a new branch named feature in one command?

    <p><code>git checkout -b feature</code></p> Signup and view all the answers

    Which command shows the current state of the working directory and the staging area?

    <p><code>git status</code></p> Signup and view all the answers

    What command would you use to stage the specific file app.js in Git?

    <p>git add app.js</p> Signup and view all the answers

    What is the outcome of executing git pull origin main?

    <p>Fetches and merges changes from the remote main branch to the local branch</p> Signup and view all the answers

    Which command is appropriate for viewing differences between your working directory and the last commit?

    <p>git diff</p> Signup and view all the answers

    What does the -m flag signify in the command git commit -m "message"?

    <p>Allows you to add a commit message directly in the command line</p> Signup and view all the answers

    How can you delete a branch named bug-fix locally?

    <p>git branch -d bug-fix</p> Signup and view all the answers

    Which command is used for integrating changes from one branch into another?

    <p>git merge</p> Signup and view all the answers

    What information does the command git remote -v provide?

    <p>Lists all remote repositories and their URLs</p> Signup and view all the answers

    To permanently remove a file named temp.log from the repository and your file system, which command should you use?

    <p>git rm temp.log</p> Signup and view all the answers

    Study Notes

    Git Commands

    • git clone creates a copy of a Git repository from its remote location (like GitHub) onto your local machine.
    • git add . stages all new or modified files in your working directory.
    • git branch <branch_name> creates a new branch with the given name.
    • git checkout <branch_name> switches to the specified branch.
    • git reset --soft HEAD^ undoes the last commit without removing its changes from the working directory.
    • git log displays the history of commits made in your local branch.
    • git branch lists all branches in your local repository.
    • git checkout -b <branch_name> creates a new branch and switches to it at the same time.
    • git status shows the current state of your working directory and staging area.
    • git add <file_name> stages a specific file to be included in the next commit.
    • git pull origin <branch> fetches and merges changes from the remote branch into your local branch.
    • git diff shows the differences between your current working directory and the last commit.
    • git commit -m "message" creates a new commit with the message provided.
    • git branch -d <branch_name> deletes a local branch.
    • git merge <branch_name> integrates changes from the specified branch into your current branch.
    • git remote -v lists all remote repositories and their URLs.
    • git fetch downloads changes from the remote repository but does not merge them into your local branch.
    • git rm <file_name> removes a file from the Git repository and your file system.
    • git branch -m <old_branch_name> <new_branch_name> renames an existing branch.
    • git push origin <branch_name> uploads your local branch to the remote repository.
    • git reset --hard HEAD^ undoes the last commit and removes its changes from the working directory.
    • git revert HEAD creates a new commit to reverse the last commit.
    • git stash temporarily saves uncommitted changes to the working directory.
    • git stash pop restores the last stashed changes.
    • git tag <tag_name> creates a new tag for the current commit.
    • git tag -d <tag_name> deletes a tag.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of essential Git commands with this quiz. From cloning repositories to managing branches, assess your understanding of Git's functionalities. Perfect for beginners and those looking to refresh their skills!

    More Like This

    Use Quizgecko on...
    Browser
    Browser