Basic GIT Commands (Ba-GIT)

Hola!
Our first conversation could have been anything, but I choose Git because… you will know ‘why’ very soon.
Well you see, git is that loyal friend who will keep all your good and bad versions.
- Good at coordinating your work between your peers
- Keeps track of your every commitment
- It is efficient in keeping up with your pace. Whether you stop, fall or rise.
The mere difference being, Git handles software development of any platform; Starting with a base code, adding/removing functionalities, backward/forward development.
A well written definition will look something like this:
“Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.”
A version-control system is like a tool, which stores your changes coherently; committed file or saved file of a repository.
Moving progressively, many encounter with a doubt in difference between Github & Git. Well answering this is not a big task. Just read the next few lines.
Git is a Version Control System, a tool to manage your source code history in local as well as production(cloud).GitHub is a hosting service for Git repositories. Where you create an account and store your code along with a chronology management UI.
Let’s get started on git: (for confusing terms, refer the appendix(end) of the blog)
- Download https://git-scm.com/downloads. comes with GIT GUI & GIT BASH.
- Successfully Install with the default settings
After installation , create a folder, get inside and right click. Select “git Bash”. We will work with bash this time.
Operation and their commands:
- Update Git : git clone https://github.com/git/git
- Initialize local git repo : git init
- Remote access : git remote add origin <copied_repo_url>
- Create a new branch : git checkout -b <branch_name>
- Delete a branch : git checkout -d <branch_name>
- Create a file to push in the prod from local repo : touch sample.txt
- Add local changes (. adds all the files) : git add [ . / <file_name>]
- Check the added files or directory from previous step : git status
- Commit the changes to be pushed in the prod: git commit -m “commit_message_goes_here…”
- Pushing the local repo changes to prod : git push origin [master/<branch_name>]
- Pulling the prod changes into local repo : git pull origin [master/<branch_name>]
- Merge branch into master : git merge <branch_name>
If we want to use the pre-existing repository from github to add changes to code review, we clone it on our ‘locally created empty repo’.
- Clone repo : git clone <copied_repo_url>
- then follow previous steps from 3 to 12
Note: -
- Master is the default branch which takes the final production code after merging all the branches. Here, ‘geeth’ is a branch created by a peer.

2. ‘<copied_repo_url>’

3. ‘prod’ means Production, your repository on github cloud

4. Repo : Repository
5. If merge conflicts occur while pulling(refusing to merge unrelated histories) : git pull origin [master/<branch_name>] — allow-unrelated-histories
6. For Visual code changes : First commit -> then pull -> then push
7. Any other repo changes : First pull -> then commit -> then push
So, this is it.
Hope you enjoyed learning git. Will come up with a new blog for git errors, some more hacks and GUI clients of git very soon. Until then hold tight.
If you like it, please applaud with the claps👏 . See ya!