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 9018327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:29:53+00:00 2026-06-16T04:29:53+00:00

I created a git repository on computer and pushed it to my server. Then

  • 0

I created a git repository on computer and pushed it to my server. Then I went into a folder on another computer that should be merged with the contents of the repository.

Here are the exact steps I executed (I reproduced it):
On the first repository:

git init
git remote add origin *repo adress*
git remote update
echo "abc" > a
git add a
git commit -a -m "Intial commit"
git push --set-upstream origin master

On the second one (the one where files get deleted):

git init
echo "def" > b
git add b
git remote add origin *repo adress*
git remote update
git pull origin master

What I expected to happen was that git would pull those files and then I could commit my local files and push it back up. But instead now my local files are gone. Did git really just delete local files without a warning (I didn’t use any force option or similar)?

Is there a possibility to get them back or is this intended and expected behavior to just remove untracked files?

Output of just git status says:

# On branch master
nothing to commit, working directory clean

I just reporduced these steps with a test repository and it happens as described: File “a” gets pulled into repository number two, but file “b” is no gone (only a is displayed by ‘ls’).

  • 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-16T04:29:56+00:00Added an answer on June 16, 2026 at 4:29 am

    Well, I find another strange thing.

    In the help of git pull, there is such a sentence as the following:

    “In its default mode, git pull is shorthand for git fetch followed by
    git merge FETCH_HEAD”

    So, I use $git fetch and then $git merge FETCH_HEAD instead of git pull origin master above. Then what amazing, file b is still there.

    So, I really don’t know what git pull origin master exactly does.

    Also, I saw an explain in

    http://git.661346.n2.nabble.com/pulling-the-root-commit-overwrites-untracked-files-without-warning-1-7-2-3-td5658622.html

    that is “git merge finds that it has no valid HEAD and therefore does a hard reset, which obviously overwrites any files already there. “

    But I really doubt this, because I can use $git merge FETCH_HEAD successfully.

    If you want to find the lost files, you can goto see Git pull deleted uncommitted changes provided by @ellotheth

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

Sidebar

Related Questions

I've created git repository, added code and pushed it to GitHub. Then locally, I've
I have created a git repo in a folder that had spaces and some
I have set up a git repository on my server. Created a new user
I have just cloned a repository in my local computer. Then I've created inside
I created a git repository projecteuler-solutions and then i wanted to remove the word
I have a git repository that was originally created using git-svn. Now I have
I have created a new git repository based on another. They will slowly be
This is driving me crazy. I created a git repository in a Linux server
I got a Git repository that I accidentally pushed a file 4 commits ago
I managed to run cvs2git several months ago and created a git repository for

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.