How to Create a GitHub Symbolic Link
What is a Symbolic Link?
A symbolic link, also known as a symlink or soft link, is a special type of file that acts like a pointer to another file or directory on your computer's filesystem. It's similar to a shortcut in Windows. It doesn't contain the actual data but stores the location of the target. Symbolic links are separate files, so deleting the link won't affect the original file.
--------------------- For detailed explanation watch this video ---------------------
Symbolic link Command
To create a symbolic link, you use the mklink
command in Command Prompt. The syntax for the command is:
mklink [options] <Link> <Target>
<Link>
: The path where you want to create the symbolic link.<Target>
: The path to the file or directory to which the symbolic link points.
Options
/D
creates a directory symbolic link./H
creates a hard link./J
creates a directory junction.
Without any options, mklink
creates a file symbolic link.
Enabling Developer Mode
Before creating a symbolic link, you need to enable Developer Mode on your Windows system. Without it, you might encounter the error message: "You do not have sufficient privilege to perform this operation."
To enabling developer mode
Open Windows Settings.
Navigate to Update & Security.
Select For developers.
Enable Developer mode.
Creating a Symbolic Link
Now that Developer Mode is enabled, follow these steps to create a symbolic link using the Command Prompt:
Open Command Prompt as Administrator:
Right-click on Command Prompt and select Run as Administrator.
Alternatively, if using VS Code terminal, make sure you open Command Prompt within VS Code.
Navigate to the Directory:
- Go to the directory where you want to create the symbolic link. For example:
I want to create a symbolic link in the content\02-operators
folder that points to the 2-conditional_oper.c
file in the content\03-conditional
directory.
Copy File Locations:
Ensure the target file does not already exist.
Use backslashes (
\
) in paths instead of forward slashes (/
).
Write the Command:
First, write
mklink
.Then, specify the symbolic link file location you want to create.
Finally, provide the original file location or target.
Example command:
mklink F:\gitdemo\learn-c\content\02-operators\07-conditional.toml ..\..\content\03-conditional\02-conditional_oper.c
You have to use
..\..\
instead ofF:\gitdemo\learn-c\
because, in GitHub, you first need to navigate out of the link directory and then go to the targeted file. The first..\
takes you from the link directory to content, the second..\
takes you from content to themain folder
, and then you can proceed to the actual file location.Use
..\
as much you needed .
Git Operations:
After creating the symlink, use git commands to add, commit, and push the changes:
git add . git commit -m "Added symbolic link" git push
Common Issues and Troubleshooting
Invalid Switch Error: Ensure you use backslashes (
\
) instead of forward slashes (/
) in the command.Also, there are many things to keep in mind. It is highly recommended to check out this video.
Why Not Use /d or /h?
Using
/d
creates a directory symbolic link.Using
/h
creates a hard link.Without options,
mklink
creates a standard file symbolic link which is a mixture of symbolic and hard links, accessible via VS Code.
Conclusion
By following these steps, you can successfully create symbolic links on GitHub, simplifying file management and enhancing your workflow. Symbolic links are powerful tools, and understanding how to use them can make your development process more efficient.
You will find that symbolic link Here: https://github.com/asem-hamid/learn-c/blob/main/content/02-operators/07-conditional.toml
Connect with me :
LinkedIn : https://www.linkedin.com/in/asemhamid/
GitHub : https://www.github.com/asem-hamid
YouTube : www.youtube.com/@AsemHamid
Subscribe to my newsletter
Read articles from Asem Hamid directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by