
Learn Basic Commands of GitHub by using Bitbucket
- January 25, 2016
- Leave a comment
Bitbucket is a web based platform for managing different types of projects using GitHub revision control systems. It allows you to create repositories for your projects (public/private) and different branches to manage the whole project in a team. Let’s consider a scenario in which you have different branches, assign a name to them with respect to team members.
All these team members will work separately on their own respective branches. After the finalization of a module or a project, these branches can be merged into a single one without any conflict. This final merged branch will be known as “Master Branch“.
Every file will automatically generate a log on Bitbucket platform, so if something goes wrong then you can revert files using these logs. The whole logging process works as a version system in which you have all previous versions files with respect to date and time.
Now, let’s have a look at some general commands of Git that are commonly used:
Initialize a Git
You have to initialize Git from the directory where you created your project. Go to that particular project using “Command Line” and create a new git repository:
1 |
git init |
Clone the Repository
You can clone the repository at your end by using the following command:
1 |
git clone /Your repository path |
If you are working on a remote server then use the following command:
1 |
git clone Your-username@your-host:/Your repository path |
Add & Commit
If you want to add files or folder to that repository then run the command given below:
1 |
git add <Your File Name/Folder Name> |
Now you have to commit a file/folder in order to proceed:
1 |
git commit -m “Your Message( optional )” |
From the aboive command, it is clear that your message is an optional thing. But its a good practice to write a message while committing files because it generates a log. That particular log will surely contain message about files/folders you committed.
Push File/Folder
After committing, the last step for sending files/folders to a remote server is “push”. You have to push it for the completion of process. See the below command:
1 |
git push origin master |
This “master” is your default branch. You can change your branch according to your need.
Pull
Pull command is used to fetch files from remote server to local server. For this, go to your working local directory using “Command Line” and use the following command.
1 |
git pull |
It will get the files/folders related to that for you.
Merge
Merge command is used to merge different files located on different branches. The files can be merged using the below command:
1 |
git merge |
User Comments