Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:19:15+00:00 2026-06-17T19:19:15+00:00

What is the difference between the following git commands: git checkout branch git checkout

  • 0

What is the difference between the following git commands:

git  checkout branch
git  checkout branch .
git  checkout  .  #<-- used at the branch

Why when I checkout different branches into different folders with first one I missed some files.
But when I am using the second command, everything is ok?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:19:16+00:00Added an answer on June 17, 2026 at 7:19 pm

    git checkout(1) does very different things whether given path specifier or not.

    1. With branch specifier only (git checkout branch) it will switch current working directory to specified branch, keeping local changes if possible and failing otherwise. If you already are on branch, it will do nothing at all. It only modifies files in the working directory that differ between HEAD and branch and fails if any of them has local modifications (indexed or not).
    2. With path specifier it will overwrite the all matching files (all files match .) with specified content:
      1. With path specifier only (git checkout .) it writes content from index. That is, it undoes unstaged local modification. To undo staged modifications, use git reset with path specifier.
      2. With both branch and path specifiers (git checkout branch .) it writes content in specified revision. It will not modify where HEAD points, so if branch is different from HEAD, there will be unstaged changes afterwards.

    Note, that the man page distinguishes additional cases for use of the -b/–branch option and -p/–patch option, but those are mostly straightforward extensions of the above cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any difference between the following two examples and should one be preferred
What's the difference between the following two? The first 1 works but the 2nd
What is the difference between the following two constructs? I am getting a different
What is the difference between following commands: start %comspec% /c script.cmd start cmd /C
Are there any difference between following ways to init self? First: - (id)init {
What is the difference between following different ways of jQuery selections. To me they
What are the differences between the following git commands? git diff HEAD git diff
What is the difference between the following class methods? Is it that one is
Is there any difference between following two ways of creating an object. Student s1
What's the difference between following relative paths? <script type=text/javascript src=../Scripts/jquery-1.2.6.js></script> <script type=text/javascript src=../../Scripts/jquery-1.2.6.js></script> <script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.