简体   繁体   中英

Beginning GIT - not fetching all files from head? How can I safely troubleshoot?

I have synced up with a git account via Eclipse. When I pull/fetch from head, it says that the project is fully updated.

However, when I compare some files to the version in head, it says that they no longer exist in the most recent revision. They do though.

Also, I should only have one change in my workspace, the addition of a file, but there are hundreds of files missing from head according to my Eclipse - this is not the case though.

I have tried -

Pulling/Fetching from the GIT perspective in Eclipse Running "git reset --hard" from command line GIT (the most recent message included in the changelog was returned - but still the same issue).

There is a hidden .git at the root folder of the project, as there should be. In the Eclipse GUI, it shows the little icon for each project reflecting that it is connected to GIT.

What is my likely issue here? How can I safely troubleshoot here? I would like to avoid being castrated for removing necessary files if possible.

Edit -

There are '?' and warning symbols next to each file - but I just fetched the project from the most recent repository. Why wont these go away?

Thank you !

Using command line:

  • git fetch - to fetch any changes from remote repository
  • git checkout master (or another branch you want to see in) - to be sure you are not in detached state
  • git reset --hard - to discard any local changes
  • git clean -xdf - to clean any untracked and ignored files from tree

Now git status should show "Your branch is up-to-date"

I think you've got lost in the process of git workflow. If you are trying to work with a remote repository, you need to make sure you've set it up correctly prior to carrying out any further work.

Be careful there since git fetch and git pull serve for different purpose.

git fetch will get information from your remote repository BUT NOT merge it

git pull will get information from your remote repository AND merge it

Also, be careful when you use

git reset --hard

what it does is besically matches your working directory to last index (HEAD). If you don't have any commits to match to this will simply maintain working directory empty. If your first commit was empty and you have files in your working directory that you didn't stash or commit, it will remove the files from your working directory and revert to your previous commit.

In order to learn what's happening in your current local repository you can do a few things to better understand the content. Use following commands to learn more

On output, this will show what files changed since last commit

git status

On output, this will show which *branch you are located on

git branch

On output, this will show you your remote branches

git branch -r

On output, this will produce a narrative of all commits you've done on CURRENT branch

git log --oneline 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM