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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:24:25+00:00 2026-05-24T17:24:25+00:00

I’ve run into a problem when I try to push only the new files

  • 0

I’ve run into a problem when I try to push only the new files I created to a different bare repository.

Say, I had two bare repository: repo1.git and repo2.git

  1. I clone a copy of repo1.git and create a new file called test_repo1.txt

  2. I push test_repo1.txt to the origin (repo1.git)

  3. I now create another file called test_repo2.txt
    I want to push ONLY test_repo2.txt from my repo1.git working copy to repo2.git repository.

So, I ran the following commands under my repo1.git working copy.

git add test_repo2.txt
git commit -m "add only test_repo2.txt file to repo2.git"
git push repo2.git master:master

Once I did the above commands,

I went in to the repo2.git working copy and find out that “test_repo2.txt” file is there but “test_repo1.txt” file is also there as well which is not what I want. I only want “test_repo2.txt” to be there not “test_repo1.txt“.

Why did the “test_repo1.txt” file end up in the repo2.git bare repository ?

Your help will be much appriciated.

Thanks

Finau

  • 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-24T17:24:25+00:00Added an answer on May 24, 2026 at 5:24 pm

    git pushes commits by following branches, not individual files. In your case you have two commits, the commit for test_repo1.txt, and the commit for test_repo2.txt, but each is in the same branch.

    When you git push to repo1 after adding test_repo1.txt, the branch only has your commit for repo one. However, once you do git add test_repo2.txt and commit it, the same branch now has both commits, so both changes are applied to repo2 when you push.

    To accomplish what you want to do, you will need to have two branches in your local working copy, let’s call them branch_repo1 and branch_repo2. You will git push each branch to its respective repo. Your procedure is this:

    1. git clone repo1 as before, and git checkout master (or whatever branch you want to start from)
    2. git checkout -b branch_repo1 to create and check out a branch for your repo1 changes.
    3. git add test_repo1.txt and git commit and git push repo1 master (replacing master by whatever branch on repo1 you want to push to)
    4. git checkout master again to go back to your starting branch (which will not have the commit for test_repo1.txt)
    5. now repeat: git checkout -b branch_repo2 to create a branch for your repo2 changes.
    6. git add test_repo2.txt and git commit and git push repo2 master
    7. Done. repo1 master will have the commit you put in the branch_repo1 branch, and repo2 master will have the commit you put in the branch_repo2 branch.

    Note that in your git push you must specify not only which repo but which branch you want to push to. Assuming you are working from master on both, you would want to do:

    git push repo1 master # while you have the branch_repo1 branch checked out
    

    and

    git push repo2 master # while you have the branch_repo2 branch checked out
    

    This will accomplish what you want to do.

    (final note: I named the branches with a prefix of branch_ instead of just repo1 and repo2 to avoid repo name/branch name ambiguity. You can name the branches whatever you want).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have thousands of HTML files to process using Groovy/Java and I need to

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.