Skip to main content

Useful git commands for pushing and pulling

First go to relevant folder from the terminal.
cd 'project path'
To clone existing git project,
git clone 'project git clone link given by git'
When you finish setting up new project, you need to download 3rd party directories to your project. To do that first go to relevant project folder in terminal and type following command.
php composer.phar update
After setting up the new project, you need to setup the database also. To do that you have to execute the sql as well.

You can do your changes in a separate branch and merge it into main branch

To create a new branch
git checkout -b "developer_develop"
You can do your developing and push it to your branch.

git status 
It will display all files in the project that you have edited. You can set the file paths that you want to push. You can put more than one file at a time. To do that use a keyboard space between two files.
git add
application/modules/property/models/property.php application/modules/property/views/property_add.php

To commit your changes,
git commit -m"branch name: A small message about what you have changed"

If you need to change the message
git commit --amend -m "branch name:new message"
You can see all commits by using 
git log
every git commit has a id. By using that id you can find changes happened in each commit.
git show 'Relevant id'
After committing your changes, you have to get others changes to your project before pushing it. To do that you have to go to your main branch and pull it.
git checkout 'main branch name'
git pull origin 'main branch name'
Then again you have to change to your branch.
git checkout 'developer_develop'
After that you can merge main branch to your branch
git merge 'main branch name'
If there are conflicts, it will show in here. After fixing conflicts, again you have to git add those changed files and commit them. After that you can push your changes to your branch.
git push origin  'developer_develop'
'developer_develop' is the newly created branch. All your changes are in this branch. 'push' and 'pull' give you to enter user name and password of gitlab if you have not set ssh key. After that the changes will be added to the main branch in the git.

When you need to pull a branch that someone else has created, you need to use
git fetch
when you need to go to another branch without loosing changes in current branch, first run
git stash
Then go to relevant branch using
git checkout 'branch name'
Do your changes, pull, push, etc...

After that you can return to your previous branch,
git checkout 'previous branch'
To get previous edited changes
git stash apply

Comments

Post a Comment

Popular posts from this blog

Start coding with CodeIgniter using PhpStorm on Ubuntu 16.04

CodeIgniter uses MVC architecture.  Model  Stores php files which are communicate with the database. Get, store, update informations to the database are handled by php files in model. Login, registration, etc...  View  Stores php files which display informations in the browser. Tables, images, descriptions, etc..  Controller   Stores php files which make the connection between model and the view. When files in the model get information, the controller will call the relevant file in the view and display them to the user. Let's start coding with CodeIgniter framework.  Step 1 : Download codeIgniter framework from  CodeIgniter . Step 2 : Copy files to a folder called Login (in my case the folder path /home/shyamali/Projects/CodeIgniter/Login) Step 3 : Then open Login folder by using PhpStorm. If you have not yet installed PhpStrom  How to install PhpStrom in Ubuntu 16.04 . Step 4 :  If you have not yet installed Apache  How to install LAMP in ubuntu

Merge Bootstrap to your current codeIgniter project in PhpStorm on ubuntu 16.04

I will be leading you how to merge bootstrap into your codeIgniter project. There are two ways that you can bootstrap in your project. Method 1 -  Load bootstrap online   In this method you have to give links of following libraries inside the head tag in view pages. //css <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> //jquery <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> //javascript <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> Method 2 -  Download and load bootstrap  You can download Bootstrap and merge it with your project. Step 1 : Download Lastest Bootstrap  and Jquery  into your computer. Step 2 : Create a folder called asserts in your codeIgniter project folder. Step 3 : Extract it and copy css, fonts, js folders to assets folder. Step 4 : Copy jquery.js f