unable to checkout git branch - file is missing in my local environment

606 views Asked by At

I'm trying to check out files in a git branch that I created.

I'm on the branch called 06-20-2018_branch on the command line.

When I list the files and directories in this branch on the command line on my local machine, there is a difference from what I see in the git web interface.

This what I see on the command line on my local machine:

-rwxr-xr-x 1 tdunphy tdunphy  4894 Jun 15 09:57 aws_rotate_keys.sh
-rwxr-xr-x 1 tdunphy tdunphy 21094 Jun 15 09:57 aws_rotate_my_keys.sh
-rwxr-xr-x 1 tdunphy tdunphy 49978 Jun 23 11:31 aws_utils.sh
-rwxr-xr-x 1 tdunphy tdunphy 49960 Jun 21 15:11 aws_utils.sh~
-rwxr-xr-x 1 tdunphy tdunphy 47854 Jun 15 09:57 aws_utils.sh.bak
drwxr-xr-x 3 tdunphy tdunphy  4096 Jun 20 21:10 singletons
drwxr-xr-x 4 tdunphy tdunphy  4096 Jun 20 21:00 source_files
drwxr-xr-x 2 tdunphy tdunphy  4096 Jun 15 09:57 text

And this is what I see in the web interface for this branch:

.vs
Directory singletons
Directory source_files
Directory text
File aws_jf_utils.sh
File aws_rotate_keys.sh
File aws_rotate_my_keys.sh
File aws_tools.sh
File aws_utils.sh
File aws_utils.sh.bak

I am missing a file called 'aws_jf_utils.sh' on my local machine.

If I try to do a git pull, it tells me that I'm already up to date with this branch:

Already up to date.

Git status shows:

git status
On branch 06-20-2018_branch
Your branch is ahead of 'origin/master' by 6 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Checking out that one file called aws_jf_utils.sh gives me:

git checkout aws_jf_utils.sh
error: pathspec 'aws_jf_utils.sh' did not match any file(s) known to git.

If I check out the one branch again, I get this:

git checkout 06-20-2018_branch
Already on '06-20-2018_branch'
Your branch is ahead of 'origin/master' by 6 commits.
  (use "git push" to publish your local commits)

How can I get at that one file I need called aws_jf_utils.sh?

1

There are 1 answers

1
dimwittedanimal On BEST ANSWER

Try this command git checkout origin/<branch-name -- path/to/aws_jf_utils.sh

The issue is likely that the file was deleted in the last 6 commits on your local version of the branch. As you stated above, the file is still there in remote.

You were close with git checkout aws_jf_utils.sh you just needed to specify that you wanted to check the remote repo for the file.