Update Local repository with server



Back

To synchronize all the changes done on the server with your local repository, use git PULL.

$ git pull origin BranchName
This will update the local files with the remote changes on the github server.


There is another way

$git reset --hard origin/BranchName



How to check the differences between two branches?

$ git diff branch_1 branch_2




How to update the server if the directory has been removed locally ?

1. git rm -r directory_name
2. git commit -m "directory_name removed"
3. git push origin branch_name




Compare same file under different branches 

git branch1 branch2 -- filename.js









Github - Branching




1. To create a new branch

$ git checkout -b branch_b1



2. To swtich back to master

$ git checkout master


3. To create a new branch from any other branch (other than master)

$ git checkout -b branch_b2 branch_b1



4. To list the available branches in your current repository

$ git branch -a


5. To delete the branch

$ git branch -d BranchName


6. To make the branch available to others through server repository

$ git push origin BranchName


7. How to sync local branch to the latest master on the server ?


We can do that, by the following steps

(Assume we are branch b1)
git fetch 
(This will reset the whole branch b1 to the server version)

git rebase origin/master(This will merge all the latest master into the branch b1)



Github



Git is really in use nowadays, and most of the companies are using it for smooth development and proper file synchronizations.

So, here is a small tutorial on using GITHUB from command line.


Create a account on github. And set your username and email on the terminal using the following git commands


  • git config --global user.name "your_name"
  • git config --global user.email "your_name@mail_domain.com"


1. Open a repository locally

$ git clone https://github.com/your_username/repository_name


Now, in Git work flow, your local repository consist of 3 stages.

a. Your Working Directory - This holds the actual files

b. Index - This is like a staging area.

c. Head - This points to the last commit you have made.


2. Suppose you create a new File, called modules.txt
So, to add this file to the server, you first have to add it to the index .

$ git add modules.txt

or 

$ git add *


3. But, to actually commit these changes

$ git commit -m "Some updating message"

This command basically moves your changes to one step ahead towards the HEAD.
But, still your changes are not yet saved to the server.


4. The process called PUSHING is responsible for saving to the server.

$ git push origin master

So, here,
origin = the local directory 
master = server repository. 

Master can be replaced by any other branch.

After this you will see something like 

Counting Objects...
Delta compression...
Writing Objects...
Total...
To https//.....


Summary

a) git Clone
b) git add
c) git commit
d) git push origin master







NVM - Node Version Manager



  • NVM stands for Node Version Manager.
  • It is really an awesome way to handle different versions of node and manipulate with them to work on different requirements.
  • So, to install it. 
  • Best Way is to install git 

(UBUNTU) 
  • apt-get install git 
  • Then, simply run
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`

  • To activate nvm, you need to source it from your shell:
$ . ~/.nvm/nvm.sh
  • Close the terminal and restart
  • So, now type 
$ nvm 
  • You will see a bunch of details about it.
  • Now, install for example, the 0.12 version of node

$ nvm install 0.12
$ nvm use 0.12



Thats all, 

Enjoy Linux..!!!
+CentOS +Ubuntu +Linux 







How to create a bootable USB device in Linux?

Thanks to Linux, it has made the creation of a bootable USB, ton of times easier than Windows.

So you just have to type the following command.

dd bs=4M if=file_name.iso of=/dev/sdb && sync


Ok, so the command looks easier, but most of the time people get stuck at of.

of means output file. Because, in output file, we cannot use the name of the file, instead we have to use the name, which the system has assigned to our USB or external HD.

So,  go to the terminal and type

df-h

There you will find a list of partitions and external medias connected to your machine.


That's all

Enjoy Linux..!!!
+CentOS +Ubuntu +Linux
  

Types of Rebooting



Cold Reboot

  • Also known as a hard reboot.
  • In this, the power to the system is physically turned off and back on again, causing an initial boot of the machine.


Warm Reboot

  • Also known as soft reboot.
  • In this the system restarts without the need to interrupt the power.






could not resolve error in github cloning...!!!!

Sometimes, we face the "could not resolve error" when we are trying to clone the github repository.

So, it happens when we have some kind of proxy set on our system.

So, either you can unset them and rerun the "git clone" command.


or

directly run this command based on the http type you are using to clone.

git config --global --unset http.proxy

or

git config --global --unset https.proxy
 





What's a proxy server?


In linux, you can check the proxy settings by using the command

$ env | grep proxy

or you can use the following commands

$echo $HTTPS_PROXY
$echo $HTTP_PROXY
$echo $http_proxy
$echo $https_proxy

If it doesn't show anything, then the proxy is not set.
Otherwise, you can unset them using the following commands.

$ unset  https_proxy
$ unset http_proxy







Text File Busy/Unexpected End of File Error in Bash

Sometimes, we get an error when we paste some bash code from windows environment to linux terminal. The error is like text file busy, or bash uninterrpreted error, Unexpected End of File etc. etc.

So, the poblem is, either the file is not writeable. 
So, chmod 777 filename

or 

the linux terminal is not able to read the input file.
So, run the dos2unix command
$ dos2unix filename.sh

And then run the bashscript
$ ./filename.sh