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

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?

Related

How to create a new file in github and add there existing files?

I have files in repository. I want them to be grouped inside a folder. How can I do this?
It seems that I need to add new file if I want to create a folder.
From how you worded your question, it seems like you're trying to work on github directly from the website.
The usual way github works is:
if you have a repo on github and you want to modify it, first 'clone' the repo into your local computer,
use these instructions https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
then just change folder structure like you would normally on File Explorer (windows) or Finder (mac),
then follow the commit instructions and 'push' up your changes to github
use these instructions
check status of your recent changes:
git status
add the files that you want to include in the commit
git add nameOfFile
check status and the file you want to include should now be green
git status
use this to send to github
git push
Overall github docs here:
https://learn.microsoft.com/en-us/training/modules/introduction-to-github/

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

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?

Add new folder with files to github

Probably one simple question. I pushed my first project to github. I've done it with Eclipse with EGit plugin. I've clicked on a project, chose to push remote and uploaded it to git. There I have created readme file online so the structure looks like this:
Git
-- AppFolder
------srcFolder
------libsFolder
------resFolder
------etc etc
-- Readme.md
I have one other folder with screenshots of the app which I would like to have outside my app folder. Something like this:
Git
-- AppFolder
------srcFolder
------libsFolder
------resFolder
------etc etc
-- Readme.md
-- ScreenshotsFolder
------screenshot1
------screenshot2
------etc etc
How can I accomplish that? I don't want to put that folder with screenshots to AppFolder. Thank you.
Locally, just create the ScreenshotsFolder in the same directory level as AppsFolder and README.md.
Then, git add ScreenshotsFolder will add the folder and all of its content (really, all content that is not in your .gitignore file if you have one).
Next just git commit then git push remote_repo remote_branch (ex: git push origin master).
If you aren't doing this via the command line, I'm sure the EGit plugin has some option to add the ScreenshotsFolder and do a commit then push...haven't used EGit myself, though. The steps are the same either way, just a different interface.
Are the files intended to be committed? If not, you could just .gitignore that directory.
edit: if the files are meant to be committed, why can't you just add and commit them like normal, but in new directory?

Cannot seem to push data to gitlab6 instance. New issues

I've created a new project, and I'm trying to add an entire directory to it. I've init'd git in the top directory, added the subdirectory, created a README with content, committed, done the 'git config' steps (user.name, user.email), added the remote. ~/.git/config is identical (save repo name) as that for another project.
When I do a 'git push -u origin master' the command line response tells me everything is up to date. When I go to look at the web instance, though, no files tab is visible.
In addition, I just created a new local repo, and did a git pull. The 2 directories were pulled over, but are empty.
I'm new (obviously) to managing a gitlab repo. I'd like to learn what I'm doing wrong, and how to accomplish what I need (a reliable repo for multiple projects). Right now, I'm fairly confused.

How to cleanup Mercurial repository?

I need to delete my "uploads" folder from the repository with all its history because it contains only junk testing data.
Please help.
You'll want to use the convert extension that ships with mercurial. Since you want to scrub a directory from the history you'll have to completely filter you're existing repository, CONVERTing it into a new one.
Assume the following made up structure of your repo:
/
src
doc
images
upload
Create a simple text file with the following content
exclude upload
You can do more with this file but keep it simple to get to your goal. The path to be excluded is relative to the repository root
Now run mercurial convert
hg convert --filemap path/to/the/textfile old-repo new-repo
Change to the directory of the new repo. Notice that mercurial created a bare/null rev repo (no content but the .hg directory). Run the following to update to your latest changset. Notice the upload directory is gone!
cd path/to/new/repo
hg update
WARNING: I do not know how this handles named branches or tags. You're on your own. At least you're not modifying the original repo. Make as many copies as you need to get it right.