Post after long time
During the time when i publish this blog on github.
I doesnt feel any challenge, its just like a cake walk(I forked a repository and make changes online whenever i feel that i want to make a post)
When i tried to install git on my local machine then i came through across some challengses and lot of questions. Which all are posted here
Why command line?
Eventhough there are plenty of GUI available online. Make your hand dirty by working on CLI.
When you are a beginner then its ok but when it comes to developers(if you’re planned to) then you must be familiar with CLI
- CLI will helps in automate your work
- CLI is only option for certain task(SSH tunnel into remote server)
- You know about what you going through.
- If you need some help from community, most of the solutions are available for CLI users(because there are plenty of GUI out there)
- It really feels good(Trust me :-)
Connecting to Github from CLI?
If you don’t want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase.
- Please make sure you are already having a ssh key, if you already have one use that one itself.
- Else you can generate a new one and use that.
- Use the following command to generate ssh key
1
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- It will prompt you to enter a passphrase.
Then you need to add this ssh key to your ssh agent. To do that
- Start the ssh agent in the background
1
$ eval "$(ssh-agent -s)"
Add your ssh key to the ssh agent. Default it is present in the
~/.ssh/id_rsa
- Copy your public key (By default it is present in the following location
~/.ssh/id_pub
Then go to your github settins option, select SSH key and then click add ssh key
Paste your public key there.
Getting & Creating Projects
Initialize a local Git repository
1
$ git init
Create a local copy of a remote repository
1
$ git clone ssh://git@github.com/[username]/[repository-name].git
Basic Snapshotting
To check the status
1
$ git status
Add a file to the staging area
1
$ git add [filename.txt]
Commit changes
1
$ git commit -m "[commit message]
Remove a file
1
$ git rm -r [filename.txt]
Sharing & Updating Projects
Push a branch to your repository
1
$ git push origin [branch name]
Delete a remote branch
1
$ git push origin --delete [branch name]
Update local repository to the newest commit
1
$ git pull
Pull changes from remote repository
1
$ git pull origin [branch name]
Inspection & Comparison
View chanes
1
$ git log
View changes in detailed manner
1
$ git log --summary
Preview changes from merging
1
$git diff [source branch] [target branch]