This question already has answers here:
How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess
(17 answers)
Closed 3 years ago.
I tried to create a .gitignore file in my repository's root directory with the command
$ touch .gitginore
in Git Bash.
But when I looked at the file from the Windows Explorer. It says it's a text document. Isn't it supposed to be of the type File?
touch .gitignore works just fine. Windows detects it as a text file but git should works perfectly.
To be sure of it, you can type ls -la and you should see all your files with their extensions, including .gitignore just like in the following picture:
Since the question does not specify any required tools, this contains a solution if you want to create a .gitignore file using command prompt or Windows Explorer.
Command Prompt:
In case one receives the following error message on a Windows 10 system in command prompt because touch is a command of git bash:
'touch' is not recognized as an internal or external command, operable
program or batch file.
You can either use the following command in command prompt (cmd):
echo. > .gitignore
or
type nul > .gitignore
as indicated here: Windows equivalent of 'touch' (i.e. the node.js way to create an index.html). This procedure will not generate a Text Document as indicated in the problem statement, but a file that appears to not have any extension.
Windows Explorer:
If you try to do it in Windows 10 Explorer by clicking right mouse button(RMB)>New>Text Document and you try to name it .gitignore you can receive the following error:
You must type a file name.
This can be overcome by giving it the filename .gitignore.. So if your git repository folder contains a folder named output which you want to suppress/not sync, you can add it to the .gitignore by editing the .gitignore. file with a text editor and adding a line that contains /output. This last procedure generates a file which is also a .txt document as indicated in the problem statement, but as mentioned by #hobbs and #Youkool that is not a problem for git. Furthermore, the last procedure is verified in Windows 10 with git version 2.16.1.windows.4.
but when I looked at the file from the windows explorer. It says it's a text document. Isn't it supposed to be of the type File
Windows says your README is of type File because it has no extension. In contrast, your .gitignore file has the extension .gitignore which Windows has been configured to report (probably by the git-for-windows installer) the type Text Document.
Please refer to How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess.
Reproducing for your easy access: In File Explorer, right click anywhere and create a new file. Type the new filename as .something. (notice the appended period) and press Enter twice, job done.
Related
I followed the steps outlined here https://laravel.io/forum/02-24-2014-a-neat-way-integrate-cmder-and-sublime-text-seamlessly, which are:
Create a new folder called 'Sublime Text 3' in the '/cmder/vendor/' location. You should also see the folders /clink, /conemu-maximus5, and /mysgit.
Download a portable version of Sublime Text 3 from their website and unzip the content into the newly created Sublime Text 3 folder.
Then, in the aliases file under /cmder/config/aliases, add: subl="%CMDER_ROOT%\vendor\Sublime Text 3\sublime_text.exe" $1 -new_console:s75V
Now I can use the subl command in a normal cmd window, but when I switch to a bash shell I get the same error, 'bash: subl: command not found'
On Windows, if you want to run some command directly in the console, you have to add the directory where it resides to the system PATH variable. There is no need to follow the instruction given in the link you provided.
solution
Find the directory where subl.exe resides and add that directory to system PATH.
see this post on how to set the path.
I am setting up my first project in Git. How do I setup git-ignore file in Windows?
I am creating my first Rails project using Vagrant and trying to configure .gitignore in Windows
Easy.
Make a file .gitignore using your text editor
In there, write the file name you'd want to ignore
You can use wildcard like: *.pyc ignoring any file with extension .pyc
If you use TortoiseGit or other Git software, it will be easier. There will be add to ignore list menu when you right click to a file.
It seems that for ignoring files and directories there are two main ways:
.gitignore
Placing .gitignore file into the root of your repo besides .git
folder (in Windows make sure you see the true file extension and then
make .gitignore.
Making global configuration %HOMEPATH%\.gitignore_global and running
git config --global core.excludesfile %HOMEPATH%\.gitignore_global
to add this to your git config.
Note: files tracked before can be untracked by running git rm --cached filename. This absolutely critical for repos that existed BEFORE you created the .gitignore
Repo exclude
For local files that doesn't need to be shared, you just add file pattern or directory to file .git\info\exclude. These rules are not committed, so are not seen by other collaborators in your project. These are machine specific configs.
Windows does not allow you to create a "dotfile" (i.e., a file whose name begins with a dot). There are three simple ways to create a .gitignore in Windows, though. In each case, you want the .gitignore in your project's root directory.
In your text editor, create a file and "Save" or "Save As". Name the file ".gitignore" and the text editor works around the OS's limitation. I use Sublime Text 3 and Vim. This method works for both (Vim would use the command :w, though).
A fallback would be to create an empty (for now) text file and save it as .gitignore.txt then go into the command shell and rename the file to .gitignore (using the command line). That will do it.
Git Bash (available in the git installer for Windows) has the "touch" command and it will create dotfiles. At the Git Bash prompt enter the command "touch .gitignore" and an empty file is created if no file existed with that name.
Add your exclusion rules inside the .gitignore file:
Starting point. This repo will give you sample exclusion patterns for (i) Windows, (ii) Rails and (iii) Vagrant. You could add those to a global gitignore file.
GitIgnore / Patterns. This section of the Git Manual explains the patterns to use in your new gitignore file. Basically, you exclude directories and files that don't need version control.
To add to previous answers that you should use a text editor to create the .gitignore file, I usually first run dir > .gitignore from a Windows command prompt or Powershell window.
This outputs the entire directory listing to a file named .gitignore .
Then it's very easy to use a text editor (e.g., Notepad ++ or Atom) to modify the file from the directory listing and not miss a file or mistype a file name.
For Windows 10 I used:
ls > .gitignore
to create a clean .gitignore file ready to just delete lines where using 'dir' I would have had to also edit out all the explanatory directory text. I needed this when vscode told me I had 5K changes after I added a virtual environment to an existing project.
When I try to do this, I get the following error:
Obviously, Windows Explorer doesn't allow me to create this type of file patterns. How can I overcome this problem?
In the File Explorer, the trick is to call your file .gitignore. and it will remove the ending .
A strange behavior but, hey!, it works 😅
Or create it from a text editor...
Windows Explorer doesn't allow you to create files that consist essentially of a file extension only. This is because Windows Explorer has the option to hide file extensions, leaving you with a file you cannot see (see Why doesn’t Explorer let you create a file whose name begins with a dot?). This is not a restriction of Windows itself, or the file system in use, though.
To create a file named .gitignore, you will have to use another tool to create it. A common solution is to create a text file (e.g. test.txt), open it in Notepad, and select Save As... to rename the file to .gitignore.
The Windows command interpreter also allows you to create files without imposing the additional restrictions of Windows Explorer. A more direct solution would then be to create the file from the command line. This can be done using the following command:
copy NUL .gitignore
Note: When dealing with files that don't have a name, it's helpful to disable the option "Hide extensions for known file types" in Windows Explorer. Otherwise Windows Explorer might show files with no names, or hide them altogether.
In cmd, just type
echo. 2>.name_you_want
or
. 2>.name_you_want
to create a file.
If creating a directory, just type
mkdir .folder_name_you_want
Use command line instead.
I was also having the same error. The problem was . at the start of file or folder name.
So I created it by command line.
You can do this with command prompt for folder creation:
mkdir .folder_name
I am using Oracle 11g. When I open a new SQL file writing the command
ed filename.sql
A new file is created in my bin folder with the name as filename but, I want them to be in separate folders for my convenience. I am developing 3 application(well for my practice only). I want them to store in different folders for each project. I tried all of the following none of them worked please tell me how can I save the files into specific folders.
ed erp/logindetails.sql
ed 'erp/logindetails.sql'
ed "erp/logindetails.sql"
ed 'erp\logindetails.sql'
ed erp\logindetails.sql
These commands except where I used "" worked and opened the default text editor with the name afiedt.buf which I am getting when I enter only edit. No files are created with any of the above command.
You're giving EDIT a relative path to the file; since your current working directory seems to be the bin directory that the SQL*Plus directory is in (is this Windows, and are you running a shortcut that sets the working directory, maybe?) it will try to create a file like %ORACLE_HOME%\bin\erp\logindetails.sql, and you're unlikely to have created an erp directory there. Giving the full path to the directory will work:
edit c:\users\dibya\projects\erp\logindetails.sql
for example.
As noted in the documentation, EDIT will search for existing files, but that involves setting an environment variable - which you'd have to change as you move between the projects. You might find it easier to edit the files in the OS and just run them from SQL*Plus.
You might also be able to use separate shortcuts to launch SQL*Plus for each project, each setting the 'start in' directory to a project-specific location - then just edit logindetails.sql would be looking in the right place by default. Or, from a command prompt cd into the relevant project-specific directory and launch SQL*Plus from there, which is effectively what a shortcut would do.
I created a simple program that takes the path of a directory as an input, creates an archive of that directory (converting it into a single file), adds a shebang to that file (so that the contents of the file can be easily extracted), and writes the file to the base directory of the specified path.
The problem is that the file does not extract itself when I double click on it. Instead the operating system (I'm using Ubuntu 11.10) tries to open it with gedit. This obviously shows the shebang, random gibberish, and the contents of the archived files.
I made the file executable, first by using chmod +x; and when it still didn't work I tried chmod 777. However it still refuses to execute the file with the shebang when I double click on it. Perhaps this is because it's not a pure text file.
Interestingly when I try to execute the file directly from command line it reads the shebang and extracts the contents of the archive properly. So there's nothing wrong with my file format. I don't know much about what operating systems do when you double click on a file but I would sure like to understand.
It surely makes no sense to add a shebang to a file if you still need to manually execute it from the command line. One advantage could be that you don't need to specify the program to open it with but I believe that's hardly an advantage. Any help will be greatly appreciated.
Update 1:
The program that creates the archive is called opm. It can be installed via the node package manager using the following command:
npm install opm
After that you simply use opm to pack and unpack directories for you. For example if I have a directory called test in my home directory then I can open a terminal and execute the following command to pack it:
opm test
This will create an archive of the directory called test.pack in the home directory. The .pack file has the shebang #!/usr/bin/opm. Opening a file with the extension .pack with opm tells it that it's an archive and opm unpacks it in the same directory.
Note: Change the name of the test.pack file if you do not want it to overwrite your existing test directory.
I added the shebang to the .pack file so that it would extract itself when I opened it. However that doesn't seem to work. Nevertheless if I run one of the following command then it works:
./test.pack
You may check my source code and make any modifications to the program as you may wish to.
Update 2:
Alright I created the following .desktop file for opm and stored it in the $HOME/.local/share/applications/ directory:
[Desktop Entry]
Type=Application
Version=1.0
Encoding=UTF-8
Name=OPM
GenericName=Object Packer and Minifier
NoDisplay=true
Comment=JavaScript Package Manager
TryExec=opm
Exec=opm %f
Terminal=false
MimeType=application/opm
Now I was able to associate .pack files with opm by right clicking on a .pack file, going to the Properties window, the Open With tab, and setting opm.desktop as the default application. Now I am able to unpack a .pack file by simply opening it.
However I would like to know how to associate .pack files with the mime type application/opm. Currently the .pack files are associated with application/x-java-pack200. How do I do so? Is it better if I use a different extension (e.g. .opm)? By associating the packed archives with the mime type application/opm will the OS open them with opm by default without having to explicitly set a default application from Properties > Open With?
If there's already a MIME-type associated with .pack then you'll want to use a different extension (.opm) to associate with your MIME-type (application/opm). The way you automatically associate a program that opens files of a specific MIME-type is with xdg-mime .
Alternatively,
Edit ~/.local/share/applications/mimeapps.list and put your MIME/application combo under [Default Applications] like so:
[Default Applications]
application/opm=opm.desktop;
Place your opm.desktop file in ~/.local/share/applications/ folder. (You've already done this)