Making changes to multiple copies of the same file in a repository - github

I'm new to github and have created a repository with multiple folders. Each folder has a copy of the same file (say abc.txt). I've linked my account to github desktop, so I have a matching local repository.
I constantly make changes to abc.txt in one of my local folders, but I want to push that change on to ALL copies of abc.txt in my online repository. The obvious alternative is to just copy and replace all copies of abc.txt on my local machine by the latest version, and push my entire local repository online, but surely there's a better way?

Related

Why Github repository keeps the original files after I moved them to a new foler within the same repo?

I created a repo on Github.
I created 2 files
I created a new folder
moved the 2 files into the newfolder from the local repo using Git bash
All files are up-to-date between local and remote
But, github still kept the original files without deleting them.
At the same time, when I used git pull, the 2 remaining files were not downloaded and appeared in my local repo anymore.
I am confused.
Can someone give me an explanation and one suggestion rather than just deleting them from Github webpage?

How do I add a file in a subfolder to a new repository?

I have a repository for a website and it has two separate remotes. One is for the website files and one for datasets and R scripts to make some data in my blog posts reproducible and archived for the future.
My local file structure looks like this.
-Website
|
|--website-files/posts/blog-post1
|/blog-post2
|r_script.R
The folder Website has two remotes one - origin - for the website, and one - blog-post - for the dumping ground for my replication files.
So, because I have cleanly added a second remote, I tried to add the file r_script.R and push it to the remote blog-post.
git add website-files/posts/r_script.R
Then, though, when I check the status, git status shows the file name as untracked listed as
../../r_script.R
The precise question: How do I add a file in a subfolder to be tracked and then to push its own unique remote? Note, when I copy r_script.R to the folder Website, and run git add r_script.R it shows up as a staged file ready for committing.
But I would really rather keep it in the subfolder to keep it clean.
Maybe should I add the repo blog-post as a submodule to the subfolder website-files/posts/ or something like that?

How to re-connect a local github repository I completely overwrote?

I have a Unity project that I messed up badly, so I downloaded the zip file of the latest repository I pushed to GitHub, deleted the local files, and dumped the content of that zip in place of the old directory. I thought this would be a seamless transition, but now GitHub Desktop is not recognizing these files as a git repository. I don't know why because there are github-specific files in there. I have made significant changes that I need to save. How do I reconnect this repository? Do I want to hit "Clone Again" or will that overwrite what I have locally with what is in the cloud? Again, I want to push what I have locally to the cloud.
For anybody else having this problem, here is what I did:
Save your local repository into a zip file someplace accessible,
like your desktop.
Completely gut your local directory--delete all
contents within the root folder. GitHub Desktop demands a clear folder to clone into.
In GitHub Desktop, where it says it
can't find your repository anymore, click the button that says
"Clone Again". This will download your cloud repository into your
local directory--the opposite of what we wanted, but at least what
comes next will work.
Delete all the cloned files that are NOT files associated with GitHub. This will prevent extraneous files from being left over when you overwrite your project files.
Copy all the non-GitHub-related files from the zip into the renewed directory.
This will restore the link between directories. Now, IT IS POSSIBLE that I deleted an essential GitHub file and did not notice (since there are at least 4 of them), and simply restoring THAT file from the cloud would fix everything. If you become disconnected like I was, I recommend trying that first in case it works and saves you time. Those are the files that get overwritten by GitHub when local files are updated.

TortoiseSVN: Merge a different repository with similar structure into current WC (with local modifications)

Here's my situation: I have a checkout from a repository that has long since been moved to a different site. This working copy of mine is from an old revision of said repository, and there are local modifications as well. The author's method of moving the repository involved deleting the contents of the old repo, leaving a single text file named something along the lines of "MOVED", with instructions.
The new repository still has the same (or similar) structure. What I would like to do is "merge" (I apologize if I'm using the wrong terminology) what is in the new repository with what I have in my working copy. I'm a little hesitant about doing this since I learned that TSVN will overwrite local changes without prompting me sometimes.
How can I go about merging the new repository in my local WC?
I suggest you to Check Out your "new" repository into another folder and overwrite the files with Copy-and-Paste. As the project structure was significantly modified, after overwriting this local copy, check file by file using Diff command.
At finishing, Commit the modifications and Update your other local copy. The local changes from this local copy won't be lost. The most that can happen is some conflicts.

what happens when I copy a checked out code folder under CVS?

I am working with a CVS repository found on a remote server.
I check out the code to a local directory code_local
Then I copy code_local, into code_local_2
Do I have now two independent local copies of the repository? Can I change files, commit, update etc. on each directory independently, is if it was done form two different computers?
(this may depend on the way CVS stores information about a local copy)
Yes I do know it's not a straight forward use of CVS, just asking if it will work
Do I have now two independent local copies of the repository?
Yes you have two independent LOCAL copies.
Can I change files, commit, update etc. on each directory
independently?
No, both copies point to the same file on the same repository. so they are independent as long as you haven't committed them. when committed the last commit operation will overwrite the previous one.
in fact there is a CVS folder beside every folder of your code that keep repository information of files inside that folder. so when you copy a project or a package, the CVS folder will be copied along with, so the same repository entries will be referenced, no matter how many copies have you made.
Even if you past the copied folder to another package hierarchy, whenever you commit the files it will replace the original files in repository where it first created.
If you want to have independent copies you have to copy and place your source code (.java) files only and commit it through Eclipse for example, in this case the CVS plug-in doesn't find any existing CVS folder beside the new folder and generates a new one in the local and new entries in the repository.