Hi everyone, i made this post to explain how i sync my git repositories without a pc (TL;DR for various reason i'm unable/unwilling to do it with my pc). There's a fantastic app for Android that you can find in F-Droid, called Termux. With this app you can transform your phone in a command line terminal, and that's what we need!
Setup Termux
After installation, at first start it will download the base environment. When it's done we need to install git.
pkg install git
and we should set our username for git:
$git config --global user.name "[name]"
We're already ready (!) to start!
Let's download your forked repository locally. The only thing we need is the URL of your fork, that you can find usually just above the file list of the code, in the top right angle, in github is under the download or copy button, something like https://github.com/silkevicious/Tusky.git
$git clone [forkURL.git]
After some moments, it will download everything. Now, we need to set up a link with the original project. Let's go in the folder that git just created.
$cd forkfolder
If you're unsure about its name, you can always run this command that list all the folders contained in the Termux environment.
$ls
Ok, once you're in we can finally set this link. Here we need the original git project URL, to keep the same example as before, it will look like https://github.com/tuskyapp/Tusky.git
$git remote add upstream [originalURL.git]
And, to check if everything is good, run
$git remote -v
It should show you 2 links for your fork and 2 for your original repo:
`origin https://github.com/silkevicious/Tusky.git (fetch)
origin https://github.com/silkevicious/Tusky.git (push)
upstream https://github.com/tuskyapp/Tusky.git (fetch)
upstream https://github.com/tuskyapp/Tusky.git (push)`
Ok we finished setup! Now we can finally sync!
Sync your repository with the master
First, we need to see what the original repo committed:
$git fetch upstream
You should see a list of branch where commits were done. Not every repo has the same name as master branch. For example pleroma has develop, pixelfed has dev. Check it out carefully! Anyway, Tusky is an easy repository and has master as name of master branch. Check if you are going to merge the upstream work in the correct branch (in this example we should put master as branch)
$git checkout [branch]
And now you can merge!
$git merge upstream/[branch]
Once done, push this syncronization data online with
$git push
It will ask you your credentials (user/password)
Aaand were done! :-)
Make edits locally
I'm going to explain it better in another post, but for now i can tell you that after an edit you just have to add a committ message with:
$git commit -m"yourmessage"
And
$git push
Update your fork
If you did some edits online instead, you should update your fork locally. It's really simple, you just need:
$git pull
And you're done!
Conclusion
I hope my guide covered all the commands and all the steps, even the most obvious. If it's not so, or you want more explaination just comment here or drop me a message on my main account. Of course there are more options and parameters i didn't covered, but IMHO for basic use aren't needed. Actually i'm editing files in web browser, and i'm still finding a good procedure that allow me to edit them locally. As far as i found it, i'll make another post! See you soon!
Comments
No comments yet. Be the first to react!