personal-website/index.json

1 line
67 KiB
JSON
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[{"content":"","date":null,"permalink":"/","section":"baalajimaestro","summary":"","title":"baalajimaestro"},{"content":" Guides, Rants and everything ","date":null,"permalink":"/posts/","section":"Blog","summary":" Guides, Rants and everything ","title":"Blog"},{"content":"If you use gitlab\u0026rsquo;s shell runner on nixos, you might have noticed, it doesnt set the home directory for the gitlab runner user. This effectively makes the applications believe that / is the home directory. If you use ssh or any similar application, this can quickly become a nightmare.\nIf you want to debug something as gitlab-runner user, this wouldn\u0026rsquo;t also work, and error out with account is not available.\nBoth of these issues can be fixed simply by adding this entry to /etc/passwd\ngitlab-runner❌63450:63450:GitLab Runner:/var/lib/gitlab-runner:/bin/bash ","date":"18 June 2023","permalink":"/posts/gitlab-runner-nixos-homedir/","section":"Blog","summary":"If you use gitlab\u0026rsquo;s shell runner on nixos, you might have noticed, it doesnt set the home directory for the gitlab runner user. This effectively makes the applications believe that / is the home directory. If you use ssh or any similar application, this can quickly become a nightmare.\nIf you want to debug something as gitlab-runner user, this wouldn\u0026rsquo;t also work, and error out with account is not available.","title":"Fixing GitLab Runner's Home Directory on NixOS"},{"content":"TikTok has changed the way world views video in the recent years. From full-length 30min videos to 30s short video, people want to entertain themselves with just an infinite scroll of videos.\nThe massive success of TikTok just brought in more like it, YouTube Shorts, Instagram Reels and much more.\nDue to the infinite scroll of media that is relevant to your liking, I often find myself losing track of time and spending hours mindlessly swiping through the videos. This takes a total hit on my productivity. The recommendation system is so good to keep you in the scroll with more and more fresh content if you keep scrolling for hours, even when you know you should be doing something else.\nWhat might seem like an entertaining and relaxing thing could get you fired for least productivity.\nSimple steps you can take to cut this down:\nUninstall Instagram app, the website works as equally good on mobile, and there are far less chances you will be hooking yourself to reels on it Uninstall/Disable YouTube app, there is plently of alternative frontends on mobile (eg: NewPipe/LibreTube) to hold your basic YT needs. I had been on a loop of spending a lot of hours on short media, and these are some small steps that did help me cut it down.\n","date":"6 April 2023","permalink":"/posts/cut-down-on-shorts/","section":"Blog","summary":"TikTok has changed the way world views video in the recent years. From full-length 30min videos to 30s short video, people want to entertain themselves with just an infinite scroll of videos.\nThe massive success of TikTok just brought in more like it, YouTube Shorts, Instagram Reels and much more.\nDue to the infinite scroll of media that is relevant to your liking, I often find myself losing track of time and spending hours mindlessly swiping through the videos.","title":"Cutting down on short media"},{"content":"I get this question a lot! The answer is usually\u0026hellip;\u0026hellip; u have to figure that out yourself. If you already know what you want to do, then the question doesnt need to be asked, or the question should have been where do I start? But, if you dont already know what you want to do, then your time might be better spent elsewhere!\nSo, here is some motivation that I typically give to everyone who asked this question to me.\nThe best contributors are always intrinsically motivated. Find out what is itching you. What is the bug that is getting on your nerves? What is some piece of software that you can never work with, and you need a whole different workflow? A completely absent feature, that you find will help you a ton? Work on those!\nIf theres nothing specific that you want to work on, then try to figure out, everyone has something or the other not suited to them. You might accustoming yourself to a bug, and never feeling its itch over time. You might have worked your way around a missing feature all this while, and never anymore felt the need for it.\nBut if you are still beating around the bush, not knowing what to do, ask your friends around. They might have a cool idea, or some small issue that needs help realizing, Get involved!\nSo, if you want to work on something new, here are my tips:\nFind problems which you are intrinsically motivated to work on. Focus on developing skills to get up to speed on new codebases fast. Dont be afraid to work on any project — new languages, tools, libraries; learn enough of them and itll only get easier to learn more. A TLDR; If you want to work on a specific project, and you have a specific goal in mind: perfect! If you dont have a specific goal in mind, try to come up with some. And if youre still drawing a blank, consider asking around.\n","date":"7 November 2022","permalink":"/posts/what-to-work-on/","section":"Blog","summary":"I get this question a lot! The answer is usually\u0026hellip;\u0026hellip; u have to figure that out yourself. If you already know what you want to do, then the question doesnt need to be asked, or the question should have been where do I start? But, if you dont already know what you want to do, then your time might be better spent elsewhere!\nSo, here is some motivation that I typically give to everyone who asked this question to me.","title":"What do I work on?"},{"content":"This is just a post to rant about what telegram did to their users.\n2 months back, telegram announced their premium subscription plan. It did look very enticing when Durov said, it would retain all the then existing features as free.\nOne such feature got pulled over to the premium plan, as of 19th August. They pulled the plugs on public channels which haven\u0026rsquo;t posted anything in a year or so. This was a major blow to many supergroups keeping their invite as private and having a standby channel to roll the links and post it. My username got snitched, and so many others who didn\u0026rsquo;t own premium had their reserved channels snitched.\nWhile this is totally agreeable that it prevents username squatting, and selling off highly wanted usernames, the unprecedented removal without informing even the owners is a red-flag. This squatting is still allowed if you are paying for their service, and that seems just absurd.\nIt is totally right that they need monetization to keep their servers running, but now they are starting to forego their promises. I do hope, they don\u0026rsquo;t spiral down into shit, making me switch to another platform altogether :)\n","date":"20 August 2022","permalink":"/posts/telegram-let-down-community/","section":"Blog","summary":"This is just a post to rant about what telegram did to their users.\n2 months back, telegram announced their premium subscription plan. It did look very enticing when Durov said, it would retain all the then existing features as free.\nOne such feature got pulled over to the premium plan, as of 19th August. They pulled the plugs on public channels which haven\u0026rsquo;t posted anything in a year or so.","title":"Telegram let down its users"},{"content":"Why use Traefik? # If you have seen me around in chats, I have been a heavy advocate of traefik over any other reverse proxy. I want you to use it as well for your deployments, if its suitable. Lemme dive into the pros of traefik over other reverse proxies first:\nTraefik is fully docker-native, can pick configuration directly when you attach a few docker labels to your containers No sort of reload or restart is required for it to pick your newly put config No need to mess with files for 99% of your configuration. Almost everything can be handled from labels. Automatic SSL, though Caddy does offer it, this is a one-up over NGINX Hassle-free redirections from HTTP to HTTPS When to deploy Traefik in your infra? # As listed above, traefik shines only when it is in a full docker infrastructure. Some people might find it really hard to move their infrastructure to full docker from a traditional server deployments. I have seen multiple people have issues when traefik was deployed into a traditional server deployment. Traefik can easily turn into a nightmare if you are not very familar with docker-based deployments.\nI would suggest deploying Traefik only if you are fully comfortable with moving your infrastructure to docker, or you already have it like that.\nNGINX vs Traefik vs Caddy Performance # Lets put these webservers on a head-on with a NodeJS webserver, and use bombardier to measure the requests they can handle per second. All of these were run on dockernet to provide an fair playing field.\nThis was all plotted to figure out how these webservers stand.\nData used with permission from raphielscape\nYou might be expecting NGINX to lead the front, but its request processing rate is pretty abyssmal compared to what people might think of it.\nTraefik, Caddy and Apache lead the front with 8000rps each, and NGINX holds a mere 2000rps.\nYou might be as well surprised how apache held almost equal to traefik and caddy. Infact better than NGINX, while the outside world thinks otherwise. These graphs are only taking 4000 concurrent connections into consideration. Apache crashed when we tried to load it with anything more than 4000 :)\nClosing Thoughts # You should deploy traefik or caddy depending on your workload. Do note, while caddy and traefik and doing almost head-on with nearly equivalent scores, Caddy still does not have support for DNS validation or certain other features like forward auth, which traefik excels in.\nAlso another issue with traefik being, it cannot serve static files, or serve php. So with traefik, you will need to have caddy bridging you with these needs.\nAvoid NGINX as much as possible, unless your workload needs a feature that isn\u0026rsquo;t there on both of these, due to how well it performs.\n","date":"9 August 2022","permalink":"/posts/when-and-why-traefik/","section":"Blog","summary":"Why use Traefik? # If you have seen me around in chats, I have been a heavy advocate of traefik over any other reverse proxy. I want you to use it as well for your deployments, if its suitable. Lemme dive into the pros of traefik over other reverse proxies first:\nTraefik is fully docker-native, can pick configuration directly when you attach a few docker labels to your containers No sort of reload or restart is required for it to pick your newly put config No need to mess with files for 99% of your configuration.","title":"When and Why to use Traefik?"},{"content":"For those who don\u0026rsquo;t know what trojan-gfw is, please google up.\nI searched far and wide on the internet, but there isn\u0026rsquo;t any proper document or article that guided me to it.\nI managed to self-host it, so I\u0026rsquo;ll share the steps with you.\nWhat you need: # Traefik (obviously) A domain (obviously) Certbot installed on the host A snakeoil caddy server (preferably some valid server) Let\u0026rsquo;s get started,\nConnect to your server over SSH and then let\u0026rsquo;s issue a certificate for the trojan to work Change the domain name to whatever your VPN would be hosted on\nsudo certbot certonly \\ --standalone \\ -m baalajimaestro@computer4u.com \\ -d something.baalajimaestro.me Once you get the certificate issued, let\u0026rsquo;s start off working on the config for trojan-go\n{ \u0026#34;run_type\u0026#34;: \u0026#34;server\u0026#34;, \u0026#34;local_addr\u0026#34;: \u0026#34;0.0.0.0\u0026#34;, \u0026#34;local_port\u0026#34;: 443, \u0026#34;remote_addr\u0026#34;: \u0026#34;trojan-caddy\u0026#34;, \u0026#34;remote_port\u0026#34;: 80, \u0026#34;log_level\u0026#34;: 2, \u0026#34;log_file\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;password\u0026#34;: [ \u0026#34;somethingsupersecret\u0026#34; ], \u0026#34;disable_http_check\u0026#34;: false, \u0026#34;udp_timeout\u0026#34;: 60, \u0026#34;ssl\u0026#34;: { \u0026#34;verify\u0026#34;: true, \u0026#34;verify_hostname\u0026#34;: true, \u0026#34;cert\u0026#34;: \u0026#34;/etc/trojan/cert.pem\u0026#34;, \u0026#34;key\u0026#34;: \u0026#34;/etc/trojan/private.key\u0026#34;, \u0026#34;key_password\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;cipher\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;curves\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;prefer_server_cipher\u0026#34;: false, \u0026#34;sni\u0026#34;: \u0026#34;something.baalajimaestro.me\u0026#34;, \u0026#34;alpn\u0026#34;: [ \u0026#34;http/1.1\u0026#34; ], \u0026#34;session_ticket\u0026#34;: true, \u0026#34;reuse_session\u0026#34;: true, \u0026#34;plain_http_response\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;fallback_addr\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;fallback_port\u0026#34;: 0, \u0026#34;fingerprint\u0026#34;: \u0026#34;firefox\u0026#34; }, \u0026#34;tcp\u0026#34;: { \u0026#34;no_delay\u0026#34;: true, \u0026#34;keep_alive\u0026#34;: true, \u0026#34;prefer_ipv4\u0026#34;: true }, \u0026#34;router\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;bypass\u0026#34;: [], \u0026#34;proxy\u0026#34;: [], \u0026#34;block\u0026#34;: [], \u0026#34;default_policy\u0026#34;: \u0026#34;proxy\u0026#34;, \u0026#34;domain_strategy\u0026#34;: \u0026#34;as_is\u0026#34;, \u0026#34;geoip\u0026#34;: \u0026#34;$PROGRAM_DIR$/geoip.dat\u0026#34;, \u0026#34;geosite\u0026#34;: \u0026#34;$PROGRAM_DIR$/geosite.dat\u0026#34; }, \u0026#34;websocket\u0026#34;: { \u0026#34;enabled\u0026#34;: true, \u0026#34;path\u0026#34;: \u0026#34;/socketplug\u0026#34;, \u0026#34;host\u0026#34;: \u0026#34;something.baalajimaestro.me\u0026#34; }, \u0026#34;shadowsocks\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;method\u0026#34;: \u0026#34;AES-128-GCM\u0026#34;, \u0026#34;password\u0026#34;: \u0026#34;\u0026#34; }, \u0026#34;transport_plugin\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;type\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;command\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;plugin_option\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;arg\u0026#34;: [], \u0026#34;env\u0026#34;: [] }, \u0026#34;forward_proxy\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;proxy_addr\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;proxy_port\u0026#34;: 0, \u0026#34;username\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;password\u0026#34;: \u0026#34;\u0026#34; }, \u0026#34;mysql\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;server_addr\u0026#34;: \u0026#34;localhost\u0026#34;, \u0026#34;server_port\u0026#34;: 3306, \u0026#34;database\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;username\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;password\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;check_rate\u0026#34;: 60 }, \u0026#34;api\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;api_addr\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;api_port\u0026#34;: 0, \u0026#34;ssl\u0026#34;: { \u0026#34;enabled\u0026#34;: false, \u0026#34;key\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;cert\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;verify_client\u0026#34;: false, \u0026#34;client_cert\u0026#34;: [] } } } What changes do you need? # The password field, generate a pretty strong password that someone cannot guess. sni and WebSocket host, to whatever domain you chose earlier The rest of the configuration should be fine, if you need to tweak anything feel free to look into trojan-gfw docs.\nSpin up a snakeoil caddyserver so that trojan can proxy to it whenever it detects non-trojan traffic.\ndocker run -d --restart unless-stopped \\ --name trojan-caddy \\ --network docker-network \\ caddy:alpine Now, for trojan itself, check to see the paths for the certificate, and the config and your HostSNI is edited properly to match your domain.\ndocker run -d --restart unless-stopped \\ --name trojan-go \\ --network docker-network \\ -v /home/baalajimaestro/dockerhome/trojan/config.json:/etc/trojan/config.json \\ -v /etc/letsencrypt/live/something.baalajimaestro.me/fullchain.pem:/etc/trojan/cert.pem \\ -v /etc/letsencrypt/live/something.baalajimaestro.me/privkey.pem:/etc/trojan/private.key \\ -l traefik.enable=true \\ -l traefik.tcp.routers.trojan-gfw.rule=\u0026#39;HostSNI(`something.baalajimaestro.me`)\u0026#39; \\ -l traefik.tcp.routers.trojan-gfw.tls.passthrough=\u0026#34;true\u0026#34; \\ -l traefik.tcp.services.trojan-gfw.loadbalancer.server.port=\u0026#34;443\u0026#34; \\ p4gefau1t/trojan-go /etc/trojan/config.json Now if you visit something.baalajimaestro.me, you should see Caddy\u0026rsquo;s welcome page. Ensure you point it to rather some valid page instead of the congratulations page of caddy, so that your ISP doesn\u0026rsquo;t grow sus of you transferring a huge amount of data to a \u0026ldquo;Congratulations\u0026rdquo; page.\nHow does this work? # We are doing a TLS passthrough on traefik so that it lets trojan handle the TLS itself for the proxy domain.\nPlaces to improve: # Put it behind a CDN (I used Cloudflare), so that the connection latency improves much better and someone doesn\u0026rsquo;t get your server IP. ","date":"4 December 2021","permalink":"/posts/trojan-on-traefik/","section":"Blog","summary":"For those who don\u0026rsquo;t know what trojan-gfw is, please google up.\nI searched far and wide on the internet, but there isn\u0026rsquo;t any proper document or article that guided me to it.\nI managed to self-host it, so I\u0026rsquo;ll share the steps with you.\nWhat you need: # Traefik (obviously) A domain (obviously) Certbot installed on the host A snakeoil caddy server (preferably some valid server) Let\u0026rsquo;s get started,\nConnect to your server over SSH and then let\u0026rsquo;s issue a certificate for the trojan to work Change the domain name to whatever your VPN would be hosted on","title":"Hosting Trojan-GFW with Traefik"},{"content":"I am not bothered about the data being collected by Google, as an ardent user of Google in every way or the other.\nAnd yet, I became a hater of Google Analytics today. All thanks to their script slowing down the site.\nMy company has been doing page speed analysis for the past few weeks on their websites, and this triggered my curiosity to check my own site\u0026rsquo;s score. It did fairly well, giving a 70 on mobile, I was kinda surprised how it is that bad, and Google safely hid gtag.js from being shown as the culprit.\nMy browser of choice, Firefox, basically killed gtag.js from running every time, so I haven\u0026rsquo;t noticed any significant change. Same with my other browser Vivaldi. When I installed Chrome for this specific purpose, I saw gtag.js take a significant loading time.\nNuking it off and rebuilding the site, bumped my score straight to 95, which seems astonishing.\nAs a result, I went with self-hosted shynet (https://github.com/milesmcc/shynet/) and it\u0026rsquo;s now available at https://analytics.baalajimaestro.me.\nMy shynet instance respects DNT, and is also GDPR compliant, should you have any issues with it, feel free to message me on any of the contact options listed here\n","date":"22 October 2021","permalink":"/posts/google-analytics-bad/","section":"Blog","summary":"I am not bothered about the data being collected by Google, as an ardent user of Google in every way or the other.\nAnd yet, I became a hater of Google Analytics today. All thanks to their script slowing down the site.\nMy company has been doing page speed analysis for the past few weeks on their websites, and this triggered my curiosity to check my own site\u0026rsquo;s score. It did fairly well, giving a 70 on mobile, I was kinda surprised how it is that bad, and Google safely hid gtag.","title":"Google Analytics, the bad guy behind bad PageSpeed Scores"},{"content":"I am Baalaji, a 22 year old,\nFree Software enthusiast DevOps Engineer at ScaleReal Technologies You might know me from\nThe Android custom ROM community, including PixelExperience, ResurrectionRemix, etc. The PaperPlane UserBot A weeb/anime centric channel \u0026hellip;and possibly many more Language # My native language is Tamil. I am fluent in English and fairly understand Hindi.\nWhy the maestro? # This tag of maestro got attached to my name when I was around 15 years old, and a certain forum had baalaji20 already taken away by someone. And the site suggested me with baalajimaestro. Little did I know, this choice will become an integral part of my online presence.\nBTW, I use Arch.\n","date":null,"permalink":"/about/","section":"About Me","summary":"I am Baalaji, a 22 year old,\nFree Software enthusiast DevOps Engineer at ScaleReal Technologies You might know me from\nThe Android custom ROM community, including PixelExperience, ResurrectionRemix, etc. The PaperPlane UserBot A weeb/anime centric channel \u0026hellip;and possibly many more Language # My native language is Tamil. I am fluent in English and fairly understand Hindi.\nWhy the maestro? # This tag of maestro got attached to my name when I was around 15 years old, and a certain forum had baalaji20 already taken away by someone.","title":"About Me"},{"content":"I would be happy to write back if you\u0026rsquo;d like to send me an email.\nFor any other small communication that can be sorted by IM, feel free to look over here for your preferred IM choice. If you are trying to contact me with IM, please ensure your message conveys your information concisely and readably, rather than sending a dumb hi/hello and expecting me to respond on it.\n","date":null,"permalink":"/contact/","section":"Contact Me","summary":"I would be happy to write back if you\u0026rsquo;d like to send me an email.\nFor any other small communication that can be sorted by IM, feel free to look over here for your preferred IM choice. If you are trying to contact me with IM, please ensure your message conveys your information concisely and readably, rather than sending a dumb hi/hello and expecting me to respond on it.","title":"Contact Me"},{"content":"This is the updated instructions, and an update-to-date (as of writing) how-to guide for vendor blob extraction\nUnlike the earlier guide, you won\u0026rsquo;t need the full rom synced. Huge kudos to the guys at LineageOS for making this possible!\nWhat you would need:\nAround like 20GB of disk space (just to be safe) Dump or OEM zip whichever is available A Popular GNU/Linux Distro Where to search if your zip is dumped already?\nGo to this link: https://dumps.tadiphone.dev/dumps\nUse the search box to search your device name If you find your device repo there, go in, and see its vendor or system build.prop if any prop matches what you need. It\u0026rsquo;s more of visual exploration for you now.\nIf the build you have is newer/the device is missing, you can request for it to be dumped here: https://t.me/dumprequests\nIn the meanwhile, you can also dump it yourself, rather than waiting for it to be dumped.\nDownload the concerned OEM zip (like MIUI, OneUI, or whatever)\nDumpyara is a universal dumper script compatible with almost all OEM zips\ngit clone https://github.com/AndroidDumps/dumpyara cd dumpyara If you have Arch Linux or Ubuntu, then simply run,\nbash setup.sh else, you have to poke into that script and match accordingly with the deps for your distro.\nWith the setup part done, Let\u0026rsquo;s get to the dumping part.\nbash dumpyara.sh ./zipname.zip Let it run for a while, and your dump should be at the working/zipname folder of dumpyara\nOnce you have the dump, let\u0026rsquo;s start to extract from it.\ngit clone https://github.com/LineageOS/android_tools_extract-utils -b lineage-18.1 android/tools/extract-utils git clone https://github.com/LineageOS/android_prebuilts_extract-tools -b lineage-18.1 android/prebuilts/extract-tools cd to the android folder and,\ngit clone your dt to the usual path like you would while building, like device/brand/codename\nClone the common tree also, if it exists\nCheck if your extract-files.sh is updated to track tools/extract-utils, if it\u0026rsquo;s not, or the file itself doesn\u0026rsquo;t exist, you need to get it from GitHub, it\u0026rsquo;s almost on every tree.\nbash extract-files.sh /path/to/dumpyara/working/zipname/ Wait and watch it do its thing\nOnce that is done, you just need to go to vendor/brand/codename and,\ngit init, commit and push it up!\nThis should be done for the common tree also which would be vendor/brand/smxx-common\n","date":"21 September 2021","permalink":"/posts/extract-vendor-2/","section":"Blog","summary":"This is the updated instructions, and an update-to-date (as of writing) how-to guide for vendor blob extraction\nUnlike the earlier guide, you won\u0026rsquo;t need the full rom synced. Huge kudos to the guys at LineageOS for making this possible!\nWhat you would need:\nAround like 20GB of disk space (just to be safe) Dump or OEM zip whichever is available A Popular GNU/Linux Distro Where to search if your zip is dumped already?","title":"Vendor Blob Extraction (v2)"},{"content":"Earlier this month, I got a new job! And they had all their code on GitHub, which seemed kinda cool too. But they wanted me to signup to GitHub with the work email. So, I did, and simply tried to add my SSH key from main account, to the work account and GitHub simply refused it. I did a huge workaround for this and will walk you through it on this post!\nWhat we would be doing?\nCreate an SSH key Create a GPG key Dynamic git configuration to match based on the folder path Creating SSH Key\nSSH is a superior means of connecting with Git servers, rather than HTTPS, in terms of speed, ease and the security ssh keys bring. Once set up, you can simply forget the need for authentication since everything happens on the fly.\nTo add upon the security we would be using the ED25519 algorithm instead of the traditional RSA.\nOpen your terminal and type:\nssh-keygen -a 100 -t ed25519 -b 521 -f ~/.ssh/id_ed25519.workplace -C \u0026#34;me@myworkplace.com\u0026#34; In case you get ssh-keygen: Command not found find out how to install ssh on your specific distro. OpenSSH is provided by default in windows and accessible on Powershell\nOnce the key generation is done, you need to store the private key very very safely. If you couldn\u0026rsquo;t figure out which your private key is, then the file named ~/.ssh/id_ed25519.workplace would be your private key and ~/.ssh/id_ed25519.workplace.pub is your public key.\nSave both the files to Google Drive or any place you trust upon for cloud storage.\nHow to add this key to GitHub?\nType this on terminal cat ~/.ssh/id_ed25519.workplace.pub\nOn windows, you can navigate to C:\\Users\\YourUsername\\.ssh\\ and open the file on notepad\nGoto https://github.com/settings/keys And press the new ssh key And copy the output into the text box provided\nCreating GPG key\nWhen you sign a Git commit, you can prove that the code you submitted came from you and wasn\u0026rsquo;t altered while you were transferring it. You also can prove that you submitted the code and not someone else. It also helps prevent untrustworthy developers from pushing backdoor commits with your name on them.\nWe would again be using the Curve25519 algorithm for increased security.\nOpen your terminal and type: gpg --expert --full-gen-key\nChoose ECC (sign only) Curve25519 on the following menu\nThe rest of the process should be self-explanatory.\nExport the private key first, so that we can save the key back in case of data corruption.\nType gpg --list-secret-keys to find the key id to export. You should see ed25519 followed by date.\nGrab the key id that\u0026rsquo;s on the next line (HEX characters like 0F35EA585\u0026hellip;\u0026hellip;)\nType this on the terminal to export your newly created gpg key\ngpg --export-secret-keys YOUR_KEY_ID \u0026gt; work.gpg Upload the work.gpg to Google Drive or any place you trust upon for cloud storage.\nSetting GPG Key on GitHub\nType this on terminal: To find your public key id, which is different from the secret key-id, Run gpg --list-keys\nAnd your key id should be displayed in the same format as the secret key did.\ngpg --export --armor YOUR_KEY_ID Goto https://github.com/settings/keys And press the new gpg key And copy the output into the text box provided\nDynamic Configuration\u0026hellip;.. (Here comes the magic)\nFirst, create a ssh config to split between our two accounts.\nEdit ~/.ssh/config and add these contents\n#personal account Host github.com-personal HostName github.com User git IdentityFile ~/.ssh/id_ed25519 #work account Host github.com-work HostName github.com User git IdentityFile ~/.ssh/id_ed25519.workplace Ensure your permissions on the file is 600 if you are using linux/mac.\nNext is to do the configuration for git.\nNuke your existing user configs by typing this on terminal\ngit config --global --unset user.name git config --global --unset user.email Once both are unset, let\u0026rsquo;s set our personal details in a new gitconfig file\ngit config --file=${HOME}/.gitconfig-personal --add user.name thatsme git config --file=${HOME}/.gitconfig-personal --add user.email personal_mail@gmail.com Once that\u0026rsquo;s done, let\u0026rsquo;s add our work details to another gitconfig file\ngit config --file=${HOME}/.gitconfig-work --add user.name thatsmebutworking git config --file=${HOME}/.gitconfig-work --add user.email thatsme@workdomain.com Our gpg settings for both accounts,\nYou need to find your key id which is not the same as your secret key id which you used for exporting it. Find the gpg key corresponding to the right email, and then copy them up!\nType gpg --list-keys and it should show your key id in a similar fashion.\ngit config --file=${HOME}/.gitconfig-personal --add user.signingkey \u0026#34;YOUR_KEY_ID\u0026#34; git config --file=${HOME}/.gitconfig-personal --add commit.gpgsign true git config --file=${HOME}/.gitconfig-work --add user.signingkey \u0026#34;YOUR_KEY_ID\u0026#34; git config --file=${HOME}/.gitconfig-work --add commit.gpgsign true For SSH redirections,\ngit config --file=${HOME}/.gitconfig-work url.\u0026#34;git@github.com-work:\u0026#34;.insteadOf https://github.com/ git config --file=${HOME}/.gitconfig-personal url.\u0026#34;git@github.com-personal:\u0026#34;.insteadOf https://github.com/ git config --file=${HOME}/.gitconfig-work url.\u0026#34;git@github.com-work:\u0026#34;.insteadOf \u0026#34;git@github.com:\u0026#34; git config --file=${HOME}/.gitconfig-personal url.\u0026#34;git@github.com-personal:\u0026#34;.insteadOf \u0026#34;git@github.com:\u0026#34; Once this is done, we are left with a small piece of work, making git load ~/.gitconfig-personal and ~/.gitconfig-work on the fly.\nThe only issue here is, you need to ensure your personal code is stored at ~/code-personal and your work code at ~/code-work. You can obviously customise these paths.\ngit config --global --add includeif.gitdir:${HOME}/code-personal/.path ${HOME}/.gitconfig-personal git config --global --add includeif.gitdir:${HOME}/code-work/.path ${HOME}/.gitconfig-work Once this is done, you can create a dir inside code-work or code-personal and do a git init inside that folder and check git config --get user.email if it matches your profile!\nIt would be actually cool if there was a way to set a global default and override, but I haven\u0026rsquo;t figured one yet. Do let me know in comments, or you can always feel free to discuss with me on any of the listed methods of communication on the home page!\n","date":"24 August 2021","permalink":"/posts/multi-git-for-work/","section":"Blog","summary":"Earlier this month, I got a new job! And they had all their code on GitHub, which seemed kinda cool too. But they wanted me to signup to GitHub with the work email. So, I did, and simply tried to add my SSH key from main account, to the work account and GitHub simply refused it. I did a huge workaround for this and will walk you through it on this post!","title":"Splitting git configs dynamically between work and personal accounts"},{"content":"I am writing this post with sheer disgust of huge nagging that I am facing for an OSS project. You might have seen me work quite a lot on Android ROMs/Kernels. Have you as a user read its license that it comes with?\nLicensor provides the Work (and each Contributor provides its Contributions) on an \u0026#34;AS IS\u0026#34; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Almost all common opensource licenses (Apache/MPL/GPL/BSD) have similar clauses of their own. Its worth taking a moment to consider the implications of this statement and what it says about the social aspects of free and open source software.\nMany people who rely on OSS software, feel entitled to get both support and maintainance at no cost. Which is absolutely not true!\nSome project maintainers may provide QA and support like RHEL/SLES, in the form of a contract. This isnt the case with FOSS, where you aren\u0026rsquo;t required to sweat and cry for the community. Let alone QA, you aren\u0026rsquo;t required to publish documentation, or even a proper commit message. My very dear friend was being called out for having \u0026ldquo;Update files\u0026rdquo; as commit message on his repos. GPL requires you to just share sources with the community, which also implies you are very much allowed to tarball it and send it up, instead of publish to a public git repo with all perfect git history.\nTip: OEMs have been doing this for years!\nIt is nice that a maintainer offers your free time, and helps you get his binaries running, but by no means they are required to. As per the free software definition you have the right to make changes to the binary and redistribute your changes to others, and to sell the software with or without those changes.\nSelling the software, this reminds me of one incident where a person was asked to make their binaries free-of-cost, for including a certain *.so file inside. There were so many people standing in support, but asking someone about this, after the sources were licensed under Apache-2.0 felt little idiotic.\nThe hostile community, is the most correct word to describe the android community. People expecting third-party AOSP forks, to perform without bugs in weird edge cases is totally not fine. You haven\u0026rsquo;t given them a WARRANTY of any sort. You aren\u0026rsquo;t required to fix those issues they describe overnight banging your head on the PC. This doesn\u0026rsquo;t imply to be rude or harass a user for asking questions at you. You could help them, or atleast redirect them to a better place to fetch help. Harassing a maintainer for publishing binaries that broke their phones, or something of the sort is also idiotic. YOU chose to make the changes. YOU are the one responsible.\nAs a maintainer, you need to be prepared to say no. Working on your project should never feel like a curse. You started it for a reason — remember that reason. Was it to lose your sanity? Or was it to have fun? Was it to solve a specific problem you had? Or was it to solve problems for someone youve never met?\nIf you enjoy helping others, then thats great! But don\u0026rsquo;t tire yourself fixing issues that don\u0026rsquo;t even bother you! Take your time fixing or attending only to those that really bother you.\nIf you are a user, and were sent to this post, please understand that all your developer\u0026rsquo;s sources are opensource. You can become a potential maintainer. Its not that you don\u0026rsquo;t know C/Java/Makefile/Soong whatever. You can learn it through time, just google up! There is tons and tons of resources that made your maintainer what he is. There are so many telegram chats dedicated to helping people with all this. Learn doing this, fix bugs, make a pull request, and boom, you have done a nice contribution to the community you were a part of!\nThanks for listening to my rant!\nThis post was sponsored by the numerous people who spammed my DMs for getting a build of PixelExperience for OnePlus 7\n","date":"22 June 2021","permalink":"/posts/android-community/","section":"Blog","summary":"I am writing this post with sheer disgust of huge nagging that I am facing for an OSS project. You might have seen me work quite a lot on Android ROMs/Kernels. Have you as a user read its license that it comes with?\nLicensor provides the Work (and each Contributor provides its Contributions) on an \u0026#34;AS IS\u0026#34; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.","title":"Android and its hostile community"},{"content":"Lets gear up with the necessary things. You would usually need a minimum of a dual core PC, some odd 4GB ram, and atleast 10GB disk free space. If you dont match the specs, dont worry, we can workaround it. And then, you need Linux installed, doesnt matter any distro, just grab up probably the latest ubuntu/openSUSE/fedora/Arch or whatever that suits you. Kernels can be compiled on literally any distro. They dont need much of dependencies. For deps, just check out akhilnarang/scripts\nLets jump into the what it is to compile a kernel. So, you have seen a developer sending fancy kernel zips for you, you wanna make your own kernel, with your name stamped on it? Well, thats too easy than you think.\nA bit of terminologies………\nSince we arent compiling a phone kernel inside a phone, you need a cross-compiler.\nWhat is cross compiler now? A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a Linux amd64 but generates code that runs on Android smartphone (aarch64) is a cross compiler.\nWhat is aarch64?\nThats the common architecture for all android smartphones today. Well, there is an aarch32 but, thats too old to be considered in current age.\nSo, where do I get a damn cross-compiler, I googled, I cant find it.\nhttps://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads\nGo to this link, and grab the toolchain AArch64 GNU/Linux target and is x86_64 host. Just use some common sense, they are right there visible on that site. They are updated regularly, so be sure to check them out once in a while.\nOk, I have the toolchains, what more? Can I compile?\nOh yes, you can almost compile now, did you clone the sources? Probably look at your OEM code or someones code you wanna compile. Clone the sources fully with git.\nNext steps, just few path changes, and finally we can hit the compile\nA toolchain prefix is what all files on that dir start with. Like aarch64-linux-gnu-*** The first part will remain almost constant. Remember the hyphen. You need to add it.\nCd to the directory where you have the cross-compiler, and then run this.\nexport CROSS_COMPILE=$(pwd)/bin/\u0026lt;toolchain_prefix\u0026gt;-\nSince you arent building a kernel for your PC, tell that to the kernel buildsystem export ARCH=arm64 \u0026amp;\u0026amp; export SUBARCH=arm64 This tells that you are building for arm64 architecture.\nFind the defconfig to build.\nThe defconfig is, in simple terms, a file containing a lot of switches and configurations that your kernel build will read and work out the binary. If you donno anything, better dont mess with it.\nAll the defconfigs are located at arch/arm64/configs/xxxxx_defconfig You need to find which defconfig your OEM/the other person used. Use your common sense again.\nNext: The glorious make.\nmake O=out \u0026lt;defconfig_name\u0026gt;\nand then make O=out -j$(nproc)\nWait for a while, it takes around 1min-1hr depending on your system specs. If those commands succeed, you will have an Image, Image-dtb, Image.gz, or Image.gz-dtb file at the end. They will be usually at out/arch/arm64/boot/Image.gz-dtb or accordingly.\nAssuming you were able to compile the kernel successfully, you now need to flash it!\nHow do I make a dtb into zip? Rename? No! Thats not how you do it. Add this dtb file to the root dir of the cloned anykernel3 https://github.com/osm0sis/anykernel3 Get to the anykernel.sh and use a bit of common sense. Thats all. Your flashable zip must be ready.\nWhats next:\nUpstreaming CAF:\nIf your device has a qualcomm snapdragon processor, then sure it has CAF support. CAF is known for improving performance and other stuff with their patches.\nWhat all can you grab?\nGenerally people grab QCACLD-3.0 and Techpack. You may also merge their own kernel repos. It contains a bit more latest patches than what your OEM would have shipped.\nHow should I merge? Merging CAF requires tags. They arent normal repos with branches. They are tagged so that you can fetch a specific tag at any point. Lets say your processor is Snapdragon 660. Look up for its codename(google), its sdm660. If you wanna know the latest tag for your processor checkout this link: https://t.me/CAFReleases Just use telegrams search button and search for your processor.\nMind it these are all tagged with android versions. If you use a kernel thats Pie and merge a CAF tag of android 10, you might be ending with 420 conflicts, not kidding.\nYou need to get some patience looking for your tag, as usual Get here, https://source.codeaurora.org/quic/la/ You will find kernel/msm-4.4, 4.9, 4.14 and a bunch others According to whats yours, copy that link Then its a usual git merge! git pull https://source.codeaurora.org/quic/la/kernel/msm-4.4/ {YOUR TAG} And boom! Again conflicts! Again resolution! QCACLD Upstreaming\nJust look out which android is your OEM/other developer using it on. Because Pie tags can work on 10 while the other way round wont. You found the tag name, so get to your terminal and follow a few steps.\nFrom LKN chat in telegram, Initial merge:\ngit remote add qcacld-3.0 https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0 git fetch qcacld-3.0 \u0026lt;TAG\u0026gt; git merge -s ours --no-commit --allow-unrelated-histories FETCH_HEAD git read-tree --prefix=drivers/staging/qcacld-3.0 -u FETCH_HEAD git commit Updating to a newer tag:\ngit fetch qcacld-3.0 \u0026lt;TAG\u0026gt; git merge -X subtree=drivers/staging/qcacld-3.0 FETCH_HEAD Repeat the above for qca-wifi-host-cmn and fw-api as well. qcacld-3.0 source: https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0 fw-api source: https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/fw-api qca-wifi-host-cmn source: https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qca-wifi-host-cmn If you happen to have some merge conflicts, just understand its some bunch of C code, you can understand the logic and figure it out.\nWell, techpack of 4.14 too follows similar scheme as you did for the qcacld. The repos you need to lookout for are audio-kernel and data-kernel\nLinux Upstream\nWhy upstream?:\nUpstreaming Linux helps you patch some critical vulnerabilities that might have been spotted after the kernel was released. The point releases like 4.14.170, 171, indicate some vulnerability or performance or maybe even some driver fixes. They dont usually add major changes.\nHow to upstream?: Linux upstream can be done from three different places as of now. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git https://android.googlesource.com/kernel/common/+refs https://github.com/android-linux-stable/\nWhat is the diff? Kernel/common is done by the same person who deals with merges on kernel.org git. Its adapted for android, if you want the bleeding edge patches working perfectly on android you need to head right here.\nAndroid-Linux-Stable:\nThis has both CAF patches and Linux stable merged. Its a sweet spot for laziness. Go checkout their readme for more: https://github.com/android-linux-stable/notes/tree/master/trees\nMerging any of these is bound to introduce a git conflict. Have fun resolving them.\nUpstreaming your kernel with ASB:\nWhat\u0026rsquo;s android security patch doing in kernels?\nWell, Google releases security patches every month, and we know that, there\u0026rsquo;s nothing new about it. But they also fix some vulnerabilities they found on their Pixel Kernel. You can merge them up, showing off to your users that security is maxxed (Bootloader unlocked, so nothing is safe)\nSo lets get started.\nGo to Google kernel/common, if you forgot/donno what it is. Its here https://android.googlesource.com/kernel/common/\nBrowse its tags, not branches!\nLook for the ASB-2020-01-05-{kernel-version}-{android-version}\nBy android version, it means your kernel\u0026rsquo;s base android version.\nDont randomly pick an android q patch over android p kernel base. Thats not gonna work!\nNow for merging the tag!\ngit pull https://android.googlesource.com/kernel/common/ {your tag you discovered}\nIts gonna throw a real bunch of conflicts, use some C knowledge and common sense to resolve them.\nBuilding with Clang:\nClang is an LLVM C/C++/Objective-C compiler, which means, its basically just another C compiler. But whats so special about clang? Its faster! When you compile 1million files, a bump of few ms on each file, bumps the whole process by minutes.\nCan every kernel build on clang? Yes, as long as your kernel is above 3.18 Do I need to do something to make it support? Grab a clang-patchset from https://github.com/nathanchance/android-kernel-clang Checkout the branches and decide which one you need.\n4.14 and above natively support clang. You dont need to mess with your source.\nHave fun hacking!\n","date":"7 July 2020","permalink":"/posts/kernel-for-newbies/","section":"Blog","summary":"Lets gear up with the necessary things. You would usually need a minimum of a dual core PC, some odd 4GB ram, and atleast 10GB disk free space. If you dont match the specs, dont worry, we can workaround it. And then, you need Linux installed, doesnt matter any distro, just grab up probably the latest ubuntu/openSUSE/fedora/Arch or whatever that suits you. Kernels can be compiled on literally any distro. They dont need much of dependencies.","title":"Kernel For Newbies"},{"content":" Warning! This article is deprecated, please use this link How to extract vendor blobs from stock rom? # I got asked this question a lot, so I\u0026rsquo;ll post it here. Its gonna just be steps on how to do it.\n⚠ Note that you need a fully synced rom source for this.\nPlace the Device Tree with the extract-files.sh inside.\nIf your device tree doesn\u0026rsquo;t have an extract-files script, get it from github, its almost on every tree.\nGrab the stock rom for your device, MIUI/OOS or OneUI whatever.\nCreate a new folder named dump and extract it there.\nNow see if it has a payload.bin or system.dat.br and vendor.dat.br\nIf it has a payload.bin, then, your device is A/B, and the job is actually very easy, # Use this tool and run the python file in it. You will now have img files ready. You are unlucky and have br files inside. # So what? We can still extract them, a bit of more work, but yes we can.\nInstall brotli from your package manager Run the following commands, it will decompress the brotli compression of your images brotli --decompress system.new.dat.br brotli --decompress vendor.new.dat.br Now we to convert the dat files to img, run these commands on terminal, to convert it curl -sLo sdat2img.py https://raw.githubusercontent.com/xpirt/sdat2img/master/sdat2img.py python3 sdat2img.py system.transfer.list system.new.dat python3 sdat2img.py vendor.transfer.list vendor.new.dat vendor.img Now you would have both the images ready for extracting. Final Step # Lets Extract the img files we have!\nCreate folders for extracting. mkdir -p system mkdir -p vendor Install P7-Zip from your package manager\nNow the extraction.\n7z x system.img -y -osystem 7z x vendor.img -y -ovendor In your folder, there would be two folders system and vendor, with many files now.\nPulling blobs # The work directory which had the system and vendor folders is assumed to be at ~/dump for now.\ncd to the device tree, and run the command\nbash extract-files.sh ~/dump Your vendor blobs would be at vendor/brand/device ","date":"10 October 2019","permalink":"/posts/extract-vendor/","section":"Blog","summary":"Warning! This article is deprecated, please use this link How to extract vendor blobs from stock rom? # I got asked this question a lot, so I\u0026rsquo;ll post it here. Its gonna just be steps on how to do it.\n⚠ Note that you need a fully synced rom source for this.\nPlace the Device Tree with the extract-files.sh inside.\nIf your device tree doesn\u0026rsquo;t have an extract-files script, get it from github, its almost on every tree.","title":"Vendor Blob Extraction"},{"content":"Before we start make sure git --version command successfully returns. If the output is something like command not found then please make sure Git is properly installed on your machine. My machine output is shown below. Output on your machine might be different.\nCommands that a user should type on his/her terminal are prefixed with the shell prompt symbol $. The output of command follows the command. Also, you don\u0026rsquo;t have to type $ on your terminal.\nPlease be nice to Mr.Git. Introduce yourself to him. Else git will blame you for not introducing yourself please tell me who you are!\n$ git config --global user.name \u0026#34;Your name\u0026#34; $ git config --global user.email \u0026#34;Your email\u0026#34; The command shown above populates a file named .gitconfig in your user home directory with configuration information.\n$ cat ~/.gitconfig [user] name = baalajimaestro email = baalajimaestro@computer4u.com Table of Contents # Why version control system? What the heck is Git? Git basics git init git status git add git commit git rm git log .gitignore files Working with branches git branch git checkout git merge Working with remote repositories git remote git pull git push git clone Github basics Why and What Pull Requests? Advanced topics git rebase git cherry-pick git alias Useful Git commands VCS: Version Control System # A version control system is a kind of database for storing your software project source code. It lets you save a snapshot of your complete project at any time you want. When you later take a look at an older snapshot (let\u0026rsquo;s start calling it \u0026ldquo;version\u0026rdquo;).\nYou can use version control system to store:\nSoftware source code Text files Writing books Sharing datasets Why version control system? # You should use version control because it offers the below:\nCollaboration among a team of Coders Versioning the code. Could create multiple branches to setup binary releases Restoring to previous versions Tracking the history (who to blame!) Backup. Old style backup methodologies like email storage, local file system or FTP backup are cumbersome. What the heck is Git? # Git is a distributed version control system. It was developed by Linus Torvalds in 2005 for linux developers and is being maintained by a large community across the world.\nEvery Git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.\nDistributed or Decentralized VCS allows many software developers to work on a project without requiring them to share a common network.\nGit basics # Let\u0026rsquo;s start by creating an empty directory git-basic. Navigate to a convenient location on your local file system and create a new directory.\n$ mkdir git-basic \u0026amp;\u0026amp; cd git-basic git init # To make any repository a Git managed repository, you can type the following command. These commands should be typed from inside the git-basic directory.\n$ git init Initialized empty Git repository in ~/git-basic/.git/ This will create a directory named .git inside the git-basic directory.\n.git is a directory where Git stores all the data. Don\u0026rsquo;t mess with the .git directory.\nIf you want to override user for this repository, then you can add user section by either editing .git/config file or using the git config --local command.\n$ git config --local user.name \u0026#34;Shekhar 123\u0026#34; If you view the contents of the .git/config file now, then you will see your change.\ngit status # Time and again we will need to know status of our Git repository. By status what we mean is the current state of the repository. E.g., what needs to be added to the index, what needs to be committed, if there is any change that we have to commit, etc., This is the command that you will use the most.\n$ git status On branch master Initial commit nothing to commit (create/copy files and use \u0026#34;git add\u0026#34; to track) git add # Let\u0026rsquo;s create a new file README.md and add a dummy message.\n$ echo \u0026#34;# Git Basics\u0026#34; \u0026gt;\u0026gt; README.md It is a good practice to create a file named README.md in your repository root that tells the purpose of the repository.\nNow, check the status of the Git repository.\n$ git status On branch master Initial commit Untracked files: (use \u0026#34;git add \u0026lt;file\u0026gt;...\u0026#34; to include in what will be committed) README.md nothing added to commit but untracked files present (use \u0026#34;git add\u0026#34; to track) git add stages the changes so they are picked up by the next commit. In Git, you can\u0026rsquo;t commit something until its tracked.\n$ git add README.md Now, check the status of your Git repository.\n$ git status On branch master Initial commit Changes to be committed: (use \u0026#34;git rm --cached \u0026lt;file\u0026gt;...\u0026#34; to unstage) new file: README.md If you have multiple files then you can use git add \u0026lt;file1\u0026gt; \u0026lt;file2\u0026gt; .. \u0026lt;filen\u0026gt; or git add --all or git add -A to stage them in one command.\ngit commit # Once you have a smallest working change, you should commit it to your version control system. Smallest working change could be a test case, a small piece of functional code, a line or paragraph in your text file, etc. You should commit often and daily. Also, every commit should strive to do exactly one change.\nAfter staging your changes, next step is to commit them into your local Git repository. To do that, we will use commit command as shown below.\n$ git commit -m \u0026#34;first commit\u0026#34; [master (root-commit) 3d34eb3] first commit 1 file changed, 1 insertion(+) create mode 100644 README.md Staging and committing are two different steps in Git. You can\u0026rsquo;t commit a change until it has been staged. If you are working with a tracked file, then you can do both of these steps in a single command.\n$ echo \u0026#34;This is my Git.\u0026#34; \u0026gt;\u0026gt; README.md Check the status of your repository. This time it will say it is a modified change.\n$ git status On branch master Changes not staged for commit: (use \u0026#34;git add \u0026lt;file\u0026gt;...\u0026#34; to update what will be committed) (use \u0026#34;git checkout -- \u0026lt;file\u0026gt;...\u0026#34; to discard changes in working directory) modified: README.md no changes added to commit (use \u0026#34;git add\u0026#34; and/or \u0026#34;git commit -a\u0026#34;) To stage and commit a change in a tracked file, you can use following command.\n$ git commit -am \u0026#34;second commit\u0026#34; git rm # Let\u0026rsquo;s suppose we added a bad file to the Git index that we want to remove.\n$ echo \u0026#34;my stupid file\u0026#34; \u0026gt;\u0026gt; stupid.txt $ git add stupid.txt To remove such a file from the Git index, we can use Git rm command.\n$ git rm -f stupid.txt To remove directories,\n$ git rm -rf crap git log # To view history of your commit logs, use the following command.\n$ git log If you want to see a commit in one line, then use --oneline option.\n$ git log --oneline There are many more options. You can refer to help git help log for more details.\n.gitignore files # Every Git repository should have another configuration file .gitignore present in the root i.e. directly inside the git-basic directory. This file is used to specify files and file patterns that you want git to ignore .\n$ echo \u0026#34;*.log\u0026#34; \u0026gt;\u0026gt; .gitignore $ echo \u0026#34;target/\u0026#34; \u0026gt;\u0026gt; .gitignore $ echo \u0026#34;dummy.txt\u0026#34; \u0026gt;\u0026gt; .gitignore The first pattern says any file with extension log will ignored. The second pattern says directory with name target will be ignored. The third pattern means file with name dummy.txt will be ignored. Now add and commit the .gitignore to your Git repository.\n$ git add .gitignore $ git commit -m \u0026#34;Adding .gitignore file\u0026#34; Working with branches # A branch represents an independent line of development. You use branch for following:\nDevelop a new feature. Once you are done with the feature, it can be merged into your main branch. Fix a bug. Your experiment playground. By default, every git repository has one branch called master. When you create a new branch, you get a new development workspace. Any change that you make to the new working directory has no impact on your previous working directory.\ngit branch # git branch command lets you work with Git branches.\nTo view all the branches, you execute following command.\n$ git branch * master branch marked with a * is the current branch.\nLet\u0026rsquo;s suppose we have to implement some new functionality. To work on new functionality, we create a new branch called feature1.\n$ git branch feature1 You can view branch list again.\n$ git branch feature1 * master One thing that is important to understand here is Git branches are just pointers to commits. When you create a branch, all Git needs to do is create a new pointer; it doesnt change the repository in any other way.\n$ git log --oneline --decorate git checkout # To switch to a branch, you use checkout command.\n$ git checkout feature1 The git checkout command lets you navigate between the branches created by git branch.\nTo create a new branch and checkout it in one command\n$ git checkout -b feature1 Let\u0026rsquo;s add our new feature now.\n$ echo \u0026#34;I will read a Git tutorial today to make sure I understand Git thoroughly.\u0026#34; \u0026gt;\u0026gt; README.md Commit it to the feature1 branch.\n$ git commit -am \u0026#34;fifth commit. Read tutorial\u0026#34; git merge (ff) # Once we are done with our feature, we can merge it back to master. First, we\u0026rsquo;ll switch to master branch.\n$ git checkout master git merge command allows you to merge an independent development line created by git branch into a single branch.\ngit merge will merge into the current branch.\nTo merge feature1 branch into master branch, execute the following command.\n$ git merge feature1 $ git log --oneline --decorate the default merge algorithm is ff i.e fast forward. When the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. This is the default behavior.\nA fast-forward merge can occur when there is a linear path from the current branch tip to the target branch.\nNow that we are done with feature1 branch, let\u0026rsquo;s delete it.\n$ git branch -d feature1 git merge (\u0026ndash;no-ff) # Create another new branch feature2 and add a new commit.\n$ git checkout -b feature2 $ echo \u0026#34;I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;sixth commit. Watch video.\u0026#34; Now checkout master again.\n$ git checkout master The --no-ff algorithm always generate a merge commit (even if it was a fast-forward merge)\n$ git merge --no-ff feature2 View logs of master\n$ git log --oneline --decorate The interesting bit is that it created a merge commit. Git uses Three-way merge algorithm.\nthe MERGE_HEAD commit i.e. the modification that we want to merge the HEAD commit i.e. the branch in which the MERGE_HEAD will be merged i.e. the branch on which the git merge command is called the ORIG_HEAD commit i.e. the best common ancestor of MERGE_HEAD and HEAD that will serve as the reference. Delete the feature branch feature2\n$ git branch -d feature2 git merge (commits in both master and branch) # Create another new branch feature2 and add a new commit.\n$ git checkout -b feature3 $ echo \u0026#34;I will try Git using tutorial https://try.github.io/\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;seventh commit. Try Git.\u0026#34; Checkout master branch and edit an existing line.\n$ git checkout master Change I will read a Git tutorial today to make sure I understand Git thoroughly. to I will read a Git tutorial https://www.atlassian.com/git/tutorials/.\n$ cat README.md # Git Playground This is my Git playground. I will learn Git today during the XKE. I will read a Git tutorial https://www.atlassian.com/git/tutorials/. I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8 Now, commit the change to master branch.\n$ git commit -am \u0026#34;fixed Git tutorial bullet point\u0026#34; Now merge the feature3 branch. This will create a merge commit.\n$ git merge feature3 View the log graph.\n$ git log --oneline --graph git merge (conflict) # In this section, we will look at scenario where there is a merge conflict. Merge conflict happens when you\u0026rsquo;re trying to merge a branch that has changed the same part of the same file as master. Let\u0026rsquo;s create a new branch feature4, make a change, and commit.\n$ git checkout -b feature4 $ echo \u0026#34;I will create a Github account today.\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;eighth commit. Signup for Github.\u0026#34; Now, checkout master, make a change, and then commit it.\n$ git checkout master $ echo \u0026#34;I will create my first repository today.\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;eighth commit. Create repository on Github.\u0026#34; If you try to merge the feature4 branch, you will get merge conflict as shown below.\n$ git merge feature4 Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result. To merge the conflict, open the file in your favorite editor. I like Atom.\n$ cat README.md # Git Playground This is my Git playground. I will learn Git today during the XKE. I will read a Git tutorial https://www.atlassian.com/git/tutorials/. I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8 I will try Git using tutorial https://try.github.io/ \u0026lt;\u0026lt;\u0026lt;\u0026lt;\u0026lt;\u0026lt;\u0026lt; HEAD I will create my first repository today. ======= I will create a Github account today. \u0026gt;\u0026gt;\u0026gt;\u0026gt;\u0026gt;\u0026gt;\u0026gt; feature4 The merged output is shown below.\n# Git Playground This is my Git playground. I will learn Git today during the XKE. I will read a Git tutorial https://www.atlassian.com/git/tutorials/. I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8 I will try Git using tutorial https://try.github.io/ I will create a Github account today. I will create my first repository today. To make the merge resolved, execute git add command.\n$ git add README.md Commit it\n$ git commit -am \u0026#34;Resolved merged conflict with feature4 branch\u0026#34; Working with remote repositories # In Git, every developer has their own local copy of the repository. It has all the repository history and branches. A developer works on their local copy and when done with the work, the changes can be pushed to a remote repository. A local repository can point to 0 or more remote repositories. A remote repository could be on Github or any other cloud VCS provider or even it could be on your own machine.\ngit remote # The git remote command lets you create, view, and delete connections to other repositories.\nTo view all the remotes, execute the following command.\n$ git remote As we have not added any remote yet, this command will not print any output.\nTo add a new remote, execute the following command.\n$ git remote add local ../git-basic-remote.git Please use correct path to your remote repository.\nTo push our repository changes to this remote repository we can run the following command. This command will be executed from inside the git-basic directory.\n$ git push local master Counting objects: 37, done. Delta compression using up to 8 threads. Compressing objects: 100% (32/32), done. Writing objects: 100% (37/37), 3.41 KiB | 0 bytes/s, done. Total 37 (delta 11), reused 0 (delta 0) To ../git-basic-remote.git * [new branch] master -\u0026gt; master Now, you can create multiple local copies of the remote repository using clone command.\n$ git clone git-basic-remote.git git-basics Cloning into \u0026#39;git-basics\u0026#39;... done. Change directory and view the contents.\n$ cd git-basic-1 You can see history of the repository using git log --oneline --decorate command.\nLet\u0026rsquo;s make a change in git-basics repository.\n$ echo \u0026#34;I will read Git in Practice book\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;ninth commit. Read book.\u0026#34; $ git push local master To get changes in our first repository i.e. git-basic, you will use pull command.\n$ git pull local master Github basics # Github is a collaborative code management platform for open source and private projects. It has social features just like any other social website like Facebook, Twitter, etc.\nYou use Github to store your code on a remote Git repository.\nYou can sign up for Github.\nCreate a repository # Create a new repository.\nGive it name git-bas and choose defaults.\nadd remote # From inside your git-basic, execute the following command.\n$ git remote add origin https://github.com/baalajimaestro/git-basic.git git push # Push the changes to Github.\nCreate pull request # Clone your repo on your local machine. Commit and push the changes to your fork Create a pull request git rebase # Rebasing is the process of moving a branch to a new base commit. It is used to keep Git history linear so you will not have merge commits.\n$ git checkout -b feature5 $ echo \u0026#34;I will prefer rebase over merge to avoid merge commit.\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;tenth commit. Prefer rebase over merge\u0026#34; Work on master branch.\n$ git checkout master $ echo \u0026#34;I will prefer merge over rebase as it is easy to understand.\u0026#34; \u0026gt;\u0026gt; README.md $ git commit -am \u0026#34;Merge over Rebase\u0026#34; Rebase command\n$ git rebase feature5 master Fix merge conflicts.\n$ git add README.md $ git rebase --continue Now view the logs using\n$ git log --oneline --decorate --graph Delete the branch\n$ git branch -d feature5 git cherry-pick # Applying a commit from one branch to another\n$ git cherry-pick \u0026lt;commit-hash\u0026gt; git alias # Allows you write your own commands or shortcuts. Like we have been using git log --oneline --decorate --graph.\n$ git config --global alias.mylog \u0026#34;log --oneline --decorate --graph\u0026#34; ","date":"18 June 2019","permalink":"/posts/git-for-newbies/","section":"Blog","summary":"Before we start make sure git --version command successfully returns. If the output is something like command not found then please make sure Git is properly installed on your machine. My machine output is shown below. Output on your machine might be different.\nCommands that a user should type on his/her terminal are prefixed with the shell prompt symbol $. The output of command follows the command. Also, you don\u0026rsquo;t have to type $ on your terminal.","title":"Git For Newbies"},{"content":"","date":null,"permalink":"/categories/","section":"Categories","summary":"","title":"Categories"},{"content":"","date":null,"permalink":"/tags/","section":"Tags","summary":"","title":"Tags"}]