Git Commands Basics

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> (C)</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> (D)</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> (A)</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> (A)</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> (B)</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 (C)</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 (A)</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 (B)</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 (A)</p> Signup and view all the answers

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

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

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

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

What information does the command git remote -v provide?

<p>Lists all remote repositories and their URLs (B)</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 (A)</p> Signup and view all the answers

Flashcards are hidden until you start studying

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

More Like This

Git Commands and Tagging Quiz
5 questions
Introduction to Version Control with Git
45 questions
Git: Systemas de Control de Version
24 questions
Use Quizgecko on...
Browser
Browser