Installation and usage of Git with commands

in Articles, Code repository, Ubuntu / 1 Comment

This post explains about installation of Git and commands which we use is frequently. Earlier we learned about installation of SVN and work with SVN. Now we can learn about Git.

Install Git into Ubuntu

sudo apt-get install  git
creating ssh key:

Generate a SSH key pair:

 ssh-keygen -t rsa

After installation we can follow the below commands to move forward.

Installation and usage of Git with commands by Anil Kumar Panigrahi

Installation and usage of Git with commands by Anil Kumar Panigrahi

Git commands

Initialization

git config --global user.name "Firstname Lastname"

Change it with your names

git config --global user.email "[email protected]"

Change it with your email address

Clone the code from Git repository
git clone [email protected][Path].git

Replace it with your repository path

Command for show branches in that repository
git branch
Command to create branch in that repository
git checkout  -b <branch name>
Command to change another branch in that repository
git checkout  <branch name>
Command to remove branch in local
git branch -D <branch name>
Command to remove branch in remote repository
git push origin --delete <branch name>
Command to PULL code
git pull [email protected][Path].git
Command to PUSH code

Once changes are donw in your files and trying to push those files to Git repository using below commands

1. Below command to check the list of changes

git status

2. Add the changed files

git add [Full path of files]

3. Commit with message

git commit -m "[Message for why we change files and features]"

4. Once done with above commands then push your code

git push [email protected][Path].git
List of commands to merge branch in that repository
git checkout  <old branch name>
git merge <new branch name>

merge conflicts ….

git mergetool
---- emerge
--- click 'Yes'
git push ... <old branch name>

With more than 9 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

Discussion 1 Comment

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>