How to Upload files to Repository in GitHub - All methods


There are many ways to upload files and folders to GitHub from our local machine/storage. Lets see few popular methods used to upload and also our own tool.

{tocify} $title={Table of Contents}

USING COMMAND LINE WINDOWS

• Download and Install Git Bash
• Go to your work directory
• Right click and select Git Bash Here

• After clicking Git Bash you can see a terminal window as shown in below image,

• Now type the following command one by one in that terminal,

git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/Philiphackerzx/philiphackerzu.github.io.git
git push -u origin main {codeBox}

Note : replace philiphackerzx with your repository name and replace Philiphackerzx with your GitHub username. {alertInfo}

• Once all commands are done, all your files are uploaded successfully you can check by opening your GitHub Repository URL.

USING COMMAND LINE ANDROID

• We use same command used in Windows but, Android doesn't have native terminal or direct Git app. So, lets see how to run GitHub commands in Android.

• Download and Install Termux
• Termux is an Terminal for Android
• Open Termux and type the following command,

termux-setup-storage {codeBox}

• This command will ask for storage permission of your device.

• Just click allow to permit.
• Then type following command to install git

pkg install git -y {codeBox}

• This command will install git
• You can type below command to check git installed correctly,

git version {codeBox}

• If it shows git version like shown in image, you are good to go..

• Now change to your website work directory. using following commands,

cd /sdcard/website/ {codeBox}

• The above command will change directory to your internal storage » folder named website. (which is my working directory I chosen, use your directory where your web files are exist)

• Now type same commands we used in windows, given below, type those commands one by one and press enter,

git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/Philiphackerzx/philiphackerzu.github.io.git
git push -u origin main {codeBox}

Note : replace philiphackerzx with your repository name and replace Philiphackerzx with your GitHub username. {alertInfo}

All done. Once all commands are done, all your files are uploaded successfully you can check by opening your GitHub Repository URL.

USING APP IN WINDOWS

• Download and Install GitHub Desktop
• Open it and Sign in
• Now create your work directory or just move to your work directory.
• Then in GitHub Desktop App and select your work directory
• All your work directory files will be automatically shown in app
• Now type any commit and press push
• All done, all your files are uploaded successfully you can check by opening your GitHub Repository URL.

USING APP IN ANDROID

• There is no option in GitHub App for Android to upload files to your repository, Only you can edit already available repo files.

• Hence, app is only recommended for other stuffs than uploading files. So, how could we upload other than command line in Android ? There is a way using browser simply.

• Open GitHub in any Web Browser
• Login to your account
• Select the repository

• If your Repository is new then you see option, uploading an existing file like shown in below image,

• Else if your Repository already had some files and you want to upload more, then press three dot menu from your Repository,

• Then choose Upload files,

• Then click choose your files,

• Select your web files from your file manager
• Add some commits if you have some.
• Then scroll down and click Commit changes button,

• All done, now your files are uploaded successfully.

Note : You can do the same process in windows or in other platforms using browser. {alertInfo}

 

CREATE OR UPLOAD FOLDERS

UPLOAD : You can push or upload folders using command line as discussed in above command line headings.

CREATE : Else you can create folder using browser,

• Open GitHub Page in Browser
• Sign into your account
• Open your Repository
• Now click three dot menu,

• Click on Create New File,

• Now in Enter filename field, Instead typing file name , just type the folder name and followed by a backslash "/" as shown in below image,

• Just press enter will create the folder,

• Now to save it successfully, Just create another dummy file as demo.txt,

• Then fill some commit if you have any and click commit button.

• All done, now click two dots to go back,

• Hurray, that's it you can see the folder here which is successfully created and useable.


ALSO CHECK


NOTE

You can change folder name from newfolder to anything as i showed as new folder just to explain. Don't forget to delete that demo file demo.txt Also keep in mind every commit took some time to saved. Hope this article is helpful, If you have any doubts, feel free to comment below. Thank you. {alertInfo}

Post a Comment

Previous Post Next Post