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
1 | sudo apt-get install git |
creating ssh key:
Generate a SSH key pair:
1 | ssh-keygen -t rsa |
After installation we can follow the below commands to move forward.
Git commands
Initialization
1 | git config --global user.name "Firstname Lastname" |
Change it with your names
1 | git config --global user.email "[email protected]" |
Change it with your email address
Clone the code from Git repository
1 | git clone git@[Path].git |
Replace it with your repository path
Command for show branches in that repository
1 | git branch |
Command to create branch in that repository
1 | git checkout -b <branch name> |
Command to change another branch in that repository
1 | git checkout <branch name> |
Command to remove branch in local
1 | git branch -D <branch name> |
Command to remove branch in remote repository
1 | git push origin --delete <branch name> |
Command to PULL code
1 | git pull git@[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
1 | git status |
2. Add the changed files
1 | git add [Full path of files] |
3. Commit with message
1 | git commit -m "[Message for why we change files and features]" |
4. Once done with above commands then push your code
1 | git push git@[Path].git |
List of commands to merge branch in that repository
1 | git checkout <old branch name> |
1 | git merge <new branch name> |
merge conflicts ….
1 | git mergetool |
1 | ---- emerge |
1 | --- click 'Yes' |
1 | git push ... <old branch name> |
2 Comments
Deploy Node.js application to Heroku - Anil Labs · August 30, 2016 at 5:38 am
[…] to settings page and get the Git […]
Foundation front-end framework installation - Anil Labs · November 22, 2017 at 7:21 am
[…] 4) To install Git […]