local git directory with files not on a github clone - gitignore

I added a directory with files to the local git repo and did the commit. When it was pushed to github it looked like it was added. When I do a clone from github the directory does not show up. I do not find a .gitignore file. Doing a check-ignore --verbose to one of the files added does not return anything.
For an experiment (with the clone up-to-date) I added a directory "gittest" with a file "hello.txt"; did the commit & push. The push appears to show the addition. A pull in the clone appears to show the addition, but the directory/file does not show. Other than starting a new repo and deleting the old one I am stuck as what to do next.

Related

How do I remove this folder from my github?

I'm a beginner to using github and I accidentally added this folder to my github but I cannot find a way to remove this please help.
I tried deleting this folder from my main folder and redoing my git pull and push and in the terminal it said that this file as already been removed. But once I pushed my file again the files that needed to be updated were updated but the folder is still on my github repo.
Try:
git rm -r <folder>
git commit -m "remove folder"
git push
The changes will only be saved when you run the commit command

Make the current commit the only (initial) commit in a Git repository that was created with GitHub Desktop

I created my first GitHub repository using GitHub Desktop (Windows). It is a real mess with many revisions that are quite meaningless and some versions of files that I would rather were never uploaded. This was the result of a lot of experimenting to get the feel for how things would appear on GitHub. I want to get rid of all the history versions.
I am tempted to just copy my files on my drive to another folder then delete the repository folder from my drive. Also delete it from GitHub.
Then create a new repository with GitHub Desktop, perhaps with the same name or with a different name then rename it to the original. Could it be a simple as that or will GitHub still retain the files somewhere?
I haven't tried this because in my searching I keep finding all the complex steps to be performed to remove histories or remove files.
I sort of feel that what I am proposing is too simple.
Any opinions?
All of this got too confusing.
I just did what I said in the start of the thread.
It seems GitHub Desktop has some Username/Password problem and won't let me "Publish branch".
So I went to GitHub and created a new repository and uploaded all the files from my local folder.
It looks good to me.
There may be problems in the future. I guess I'll cross that bridge when (if) I come to it.
An alternative approach is to switch to command line and:
delete the .git folder in your repository
recreate it (git init .)
reset the origin remote: git remote add origin https://github.com//
Make a first commit with your current content:
git add .
git commit -m "first commit"
overwrite everything on the remote repo
git push --force -u origin master
The end result will be the same repo but with only one commit.
You can then switch back to GitHub Desktop.
From here.
First make sure you have Git for Windows installed, you are going to need to do git commands manually sooner or later.
Go to your local repository on your computer where your project is located. It's a good idea to show hidden files so you can see that you have the .git-folder and that the .gitignore-file is in place.
Go to the folder where the .git-folder is, right-click and click git bash here.
Now enter these commands:
Create Orphan Branch – Create a new orphan branch in git repository. The newly created branch will not show in ‘git branch’ command.
git checkout --orphan temp_branch
Add Files to Branch – Now add all files to newly created branch and commit them using following commands. Don't forget .gitignore!
git add .
git commit -m "the first commit"
Delete master Branch – Now you can delete the master branch from your git repository.
git branch -D master
Rename Current Branch – After deleting the master branch, let’s rename newly created branch name to master.
git branch -m master
Push Changes – You have completed the changes to your local git repository. Finally, push your changes to the remote (Github) repository forcefully.
git push -f origin master
Git overview

Pushing folder's contents into a folder inside a repository? [duplicate]

I cloned a repository to my desktop machine using git clone sshurl. As expected, this created a folder in my desktop.
Now, instead of a single file, I want to push a whole folder into git. For example, the folder that I cloned is named project_iphone. Now I add another folder called my_project into project_iphone. The my_project folder contains lots of files and folders as well.
My question is, how should I push my_project folder to the server?
Step-by-step instructions would be helpful.
Thank You.
You need to git add my_project to stage your new folder. Then git add my_project/* to stage its contents. Then commit what you've staged using git commit and finally push your changes back to the source using git push origin master (I'm assuming you wish to push to the master branch).
In order to push any folder from git bash, you have to make a single file it could be anything text or etc.
If you try to push an empty folder your git bash will not give you an error but when you refresh your GitHub you will not see that folder, so in order to push any folder just make a single file and push, after that you can add your stuff and delete the previous file(if you want to).
to push follow the below commands
-git add (folder name)
-git add . (in order to push everything)
-git commit -m "anything" (to keep track of your changes)
if not added remote origin then do this
-git remote add origin (your repo link) then to push files
-git push -u origin main
to push on the master branch
-git push -u origin master
look if you have already created a repo then do
-git push -u origin master
You can't push a new empty folder. First you must create at-least one new file in the new folder and then you can add, commit and push it.
You can directly go to Web IDE and upload your folder there.
Steps:
Go to Web IDE(Mostly located below the clone option).
Create new directory at your path
Upload your files and folders
In some cases you may not be able to directly upload entire folder containing folders, In such cases, you will have to create directory structure yourself.

How to upload in an Existing Repository?

I have a repository. I pushed files from a folder. Now I don't want to create new Repository. But I want to push files from a new Folder. The folders are almost same. How can I do this with command?
Assuming that you already have the repository created, you can do the following.
cd newfolder
git clone <link-to-clone-from>
Then copy the files to new folder. Check git status -s to see a summary of changed files in new folder after you copy files. Using git diff or beyondcompare can show you the exact changes that you are about to commit next. If everything looks fine, continue with the next steps
git add -a
git commit -m "your commit message"
git push origin master
Assuming you have two folders:
- Old repo folder
- .git
- My old folders
- My old files.
- New repo folder
- My new folders
- My new files.
And you want to replace all stuff in the remote repo from the old repo folder with the new repo folder.
To do that:
First, delete all content except the folder: .git in the Old repo folder.
Then, copy everything except the folder: .git from the New repo folder to the Old repo folder
And run commands in the Old repo folder:
$ git status
To get if everything is fine. Git will detect that you have replaced a lot of files and deleted many of them. Check the output.
$ git add . && git commit -m "Replace with new content"
$ git push
And this will save your changes and send it to remote server.

Not able to delete a suspicious file from github repository

I was trying to push assignment6 folder in this repository and when I did and checked it, it wasn't uploaded and instead had this weird folder with the same name, which is empty inside maybe because it doesn't open.
I want to delete it. I tried git pull origin master, hoping that it will be downloaded to my laptop and I will delete it, but it says repository is up to date. In the end, I had to rename assignment 6 in my laptop to 6assignment and push it and it successfully did, but I still have that weird folder left in my repository.
Now, I want to remove this weird folder.
git rm -r --cached Assignment6
git commit -m "Removed folder from repository"
git push origin master
removed assignment6 folder from repository.
In order to rename 6assignment folder to assignment6 in repository, repeated above steps again. Doing so, also deleted 6assignment. Then renamed 6assignment folder from my local machine to assignment6, and then pushed it.
P.S. Making the repository back to private now.