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

  • Home
  • SEARCH
  • 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 4545636
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:50:28+00:00 2026-05-21T15:50:28+00:00

I’ve started to learn git in the past few days and I have a

  • 0

I’ve started to learn git in the past few days and I have a basic question.

Imagine this situation:

You create an empty folder and in there you create a foo.txt file.

In order to push the data into the remote repository (e.g. github), you make the following commands:

  • git init -> in order to initalize the repository in the folder
  • git add . -> in order to add to the index all the files in the folder, in this case foo.txt
  • git commit -m "First commit" -> We make the first commit
  • git remote add origin git@github.com:username/gitrepository.git -> We add the github repository
  • git push origin master -> We push the changes to the remote repository

    1. Now in the github repository you have only a foo.txt file.

    2. So now you are in another machine and want to use the repository, so you create an empty folder and pull the data from the remote repository.
      Then you create a file named bar.txt, delete foo.txt, add the file (bar.txt) to the index, make a commit and push the changes to the remote repository.

    3. Now in the repository we have only the bar.txt file

    4. But now in the first machine we still have the foo.txt file, and if we make a pull from the remote repository we have foo.txt and bar.txt.

But that’s not what I would like to do, I would like to pull all the files from the repository and work only with those files. So in this example, if I only have now bar.txt in the repository, when I make a pull I don’t want any other files in my project folder.

How do you manage that?

  • 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-05-21T15:50:29+00:00Added an answer on May 21, 2026 at 3:50 pm

    I think you missed a step in 2.

    You have to remove the foo.txt file from the index. It requires a specific command (“git add .” only puts file to the index but doesn’t remove files) :

    • git rm foo.txt
    • git add -u (removes from the index all files that are not anymore in the workspace)

    Then commit.

    At step 3, after a pull on the first computer, the foo file should have disappeared.

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put

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.