Recently I dabbled into GIT… due to it being the standard for vcs and used by cool guys :D… but also because few in-house projects in my workplace were using it and me being DevOps guy needed to deal with it for CI/CD cycles. I felt that unlike SVN, GIT is more CLI friendly. All you need to do is to remember few commands and you are pretty much set for 70% of your use.
For sake of simplicity I will use GitHub as reference and source. Also, this post is for more like my reference and as of now I am mainly using most of commands without any specific switch so all examples are like that as well.
Ok then… First command in my cheatsheet is
git clone url_of_repo
This command clones remote repo to your local drive. Of course, you can clone repo using SSH as well. It does more than that but that is simplest explanation :D.
This perhaps the most frequently used command. This will show status of local report and will show if there are any uncommitted changes.
Actually this command has couple of variation based on what your are trying to do,
- git add file_name
- git add .
- git add -A
1st one adds specific file, 2nd one adds all modified and new files from current directory and 3rd option adds all files across whole repo.
When you run this command, it adds changes to staging repo.
Next command in my cheat sheet is,
git commit -m “some message about commit”
This command will add changes that you did to staging to commit repo (i.e. records your changes to repo).
Now the last command… if you do “git status”, it will show that there are some changes already committed in your local repo but those changes are missing in “main” repo.
That brings to last command of my cheat list…
Running this command, pushes changes from your local repo to “main” (i.e. remote) repo
I think SVN being my background, GIT can get confusing some time but at same time being long time SVN user… I know the most hated issue of SVN is merging changes while multiple developers working… to me this is where GIT shines.
That’s it for now…