Tutorial How to upload files on Github repo properly using an Android phone

TheLGL

Awesome Active Platinian
Original poster
Skilled
Feb 19, 2020
156
4,213
193
UK
I have seen most peoples uploading a .zip file instead uploading files normally. I understand the case that only device they have is an Android phone, and uploading multiple files isn't really possible, but this way is really bad practice. We want to view source directly without having to download zip first. When that’s the case, what do you do? Thanks to a handy tool called MGit, it is possible to install the Git client on a mobile device.

Using Git is not just a simple file uploading, it is a version control system and it requires a necessary steps to upload files. It may be confused for the beginners who are new to Git. I’m going to walk you through the process of getting this up and running. I’ll demonstrate on an Android emulator because my old phone sucks, but I don't feel the need to use my smartphone for other things than calling, browsing and important task

I will only cover how to upload files on your repo. To learn more about Git, please refer to "Git for Beginners" or Git documentation. Google is your friend :))
I'm also don't have much experience with Git, so I may have explained it incorrectly

What you need
The only things you need are a device running version 5.0 or newer of the Android platform and a GitHub account. That’s it.

Let’s make this happen.

Creating Personal access tokens
We will need a personal access token to use in place of a password with the Git client

Go to your token settings in Github settings
Click Generate new token

Image 1649324630.png


Give your token a descriptive name. To give your token an expiration, select the Expiration drop-down menu, then click a default or use the calendar picker.

Select the scopes, or permissions, you'd like to grant this token. To use your token to access repositories from the command line, select repo.

Image 1649324935.png


Click the green button Generate token

Your token will be created.

Make sure to copy your token now. You won't be able to see it again!

Warning: Treat your tokens like passwords and keep them secret. When working with the API, use tokens as environment variables instead of hardcoding them into your programs.

Image 1649324956.png


Creating new Github Repo
You can do that by click on "+" sign > New repository or go to github.com/new

Before you create, make sure to add a README file or you can add other files later of your choice, in order to avoid strange error when MGit when working with empty repo

Image 1649342493.png


Setting up MGit
The first thing to do is install MGit. This is done from the Google Play Store

And you need to install file manager app if your choice. we will use X-plore

Once installed, open the app.

Click on plus "+" sign, and give your repo in the Remote URL. Click CLONE

Image 1649340045.png


Your repo will be cloned. It is stored on /storage/emulated/0/Android/data/com.manichord.mgit/files/repo

Image 1649340518.png


You can now add files you want to be pushed to your repo. I used X-plore and copied my project to my Git-Test repo

Image 1649342894.png


Go back to MGit, and open up your repo. The files will be shown

Image 1649340855.png


This is where it gets slightly tricky. This isn't a simple uploading like I said before. Click on the 'hamburger' menu on the right-top corner, and click Add all to stage. We want to upload all files

Image 1649340873.png


We want to add user and email for commit infomation, this is necessary. Scroll down and click Raw config

Give your user and email. You can give fake info if you want, it doesn't harm

Image 1649343345.png


We need to commit the change. Open the menu and Click Commit

Image 1649340873 - Kopi.png


Give your appropriate message and commit

Image 1649343317.png


Now the final step, pushing, which means uploading. Open the menu and Click Push

Image 1649340873 - Kopi - Kopi.png


Check Push all? and Force push? and click on origin

Image 1649343409.png


Upon pushing, it will ask for Authentication. Give your Github username and your TOKEN key we created previously, not your Github password. Save user and pass if you want. Click DONE

Image 1649343433.png


Once you authenticated, and when successful, a message dialog will look like this

Image 1649343443.png


And there you go. A handy way to work with Git on your Android device. Now… git to work.

Editing, adding or removing files
When you do, you need to follow the following steps again

1. Add all to stage (you only need when you add or remove files. Otherwise, do if you have issues pushing some files)
2. Commit
3. Push
 
  • Like
Reactions: GNaFF