When I push a cpp file to the github repository then an exe file gets added. What can I do so that I don't get those exe files - github

Whenever I push a cpp file to my github repository an exe file gets added to the repository. I don't want that exe file.How to do that?

you want the file not be tracked across everyone's repositories create a pattern as below in .gitignore file. This file can either be in root directory of you application or a the directory you .cpp and .exe files are in.
*.exe
If you want .exe files to be ignored for only you. Then you can put above pattern in .git/info/exclude
Follow this link for more info:
https://www.atlassian.com/git/tutorials/saving-changes/gitignore

Related

How to recover files from .gitignore

while uploading files to the repository in GitHub, I accidentally click to the button to ignore the files from the upload. Now these files are in a folder called '.gitignore'.
How can I recover these files?
I'm able to see and modify them, I just want to know how to upload them in the repository.
Thanks in advance
I think you misunderstand the concept of .gitignore "folder".
It is instead a text file, with the path of the ignored directories or files.
Consider the following .gitignore file.
foo/bar.txt
foobar/
This will tell git to ignore the directory foobar as well as the file foo/bar.txt, and therefore you won't be able add the files to a commit or push it to a remote repository.
But you can simply remove a file from the list of ignored files and directories by opening the .gitignore file, deleting the line with the corresponding file and saving the .gitignore file. You then should the be able to add the file to a commit and push it to a remote repository.
More information about .gitignore can be found here

.gitignore not ignoring a folder within a directory

It seems a straightforward one, but having researched multiple ways to do it, I can't gitignore a folder within a directory.
I have a root directory which contains all of my code in it. Because it has some back-end NodeJS stuff in it, it has a 'node_modules' folder which contains hundreds of files. As a result, when I try to upload the entire parent folder, GitHub says there's too many files to upload and tells me to reduce the number I'm uploading.
The crucial part is though, the folder has to be uploaded as a whole, as it itself is within a GitHub repository with other files with different folders in.
That means when I go onto my repository, I need this folder's files to display within the folder, and not separately within the repository. I need all of the files to be within this folder, within the parent repository, excluding the node_modules folder.
For example ->
Parent repository -> Child Directory (what I'm uploading) -> Individual files
I've tried to add the node_modules folder to my gitignore through the following methods:
Adding: node_modules/ to my gitignore file
Writing: echo node_modules >> .gitignore through my terminal
Adding a separate gitignore file within my node_modules file with a * in it
None of them have worked and I can't find any other solutions. For reference I'm using a Mac.
Does anyone have any idea what I'm doing wrong, or how it'd be best to do it?
By default, you do not need to include the node_modules folder in your repositories because the package.json file contains all of your project's dependency information. This means that anyone who clones your repository can run npm install and have the entire node_modules folder without problems.
To solve this you can create your own .gitignore file, creating a new file at the root of your project and renaming it to .gitignore (writing exactly that way). Then you can open it with any text editor and add */node_modules to one of the lines.
This will likely solve your problem.

How do I replace a zip file in a forked repository

I need to update a zip file forked from another user's github repository.
I have a repository forked from https://github.com/k2zia/AD985XSPI that contains only two files, a readme, and a zip file (AD985XSPI.zip). The zip file is an Arduino library that does not contain a "libraries.properties" file, a requirement that has been added since the time the original repository was created. I downloaded the zip file, unzipped it, added a "libraries.properties" file, rezipped, and now need to replace the existing zip file in my repository.
I am unclear on how to accomplish this task.

Does sourcetree automatically load .gitignore file?

I create .gitignore file by textedit on mac.
( by following Adam of link Git ignore file for Xcode projects I create empty txt format file, and copy and paste it.)
And I put that file in .git folder in the project folder.
Then, Does sourcetree will 'automatically' load this .gitignore file as soon as I put the file in that folder ?
Put it directly in the project folder not to .git. It will be automatically loaded by sourcetree from that folder

Is there a way to control what gets into a GitHubs zipball?

Every GitHub repo has the Download ZIP button, but is there a way to control what gets into the final zipball. For example we do not need and hidden files there, or even - unit tests.
Excerpt from Pro Git book:
You can tell Git not to export certain files or directories when
generating an archive. If there is a subdirectory or file that you
don’t want to include in your archive file but that you do want
checked into your project, you can determine those files via the
export-ignore attribute.
For example, say you have some test files in a test/ subdirectory, and
it doesn’t make sense to include them in the tarball export of your
project. You can add the following line to your Git attributes file:
test/ export-ignore
Now, when you run git archive to create a tarball of your project,
that directory won’t be included in the archive.