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
Nice one
ReplyDeleteThanks
Delete