Over the past several months, I’ve had to learn a new skill – a technical skill which I had no clue about and it’s related to software development. I decided to write some of the commands and stats I”ve learnt and may potentially forget. So here we go, let me share with you some of the tools I’ve used and the commands I’ve learnt:
Bitbucket
Our software development agency uses Bitbucket and I just fell into learning this. It’s an Atlassian product and there is a Free tier for Small teams. You basically store all your code on Bitbucket and it allows you to track and manage code. Updating code is so much easier when using GIT. In my situation, our development agency makes changes to the code and pushes the changes to a repository (Bitbucket) and then on our systems, whether it’s our development or production server we pull down the changes.
Here’s what I had to do to install the GIT software on our Virtual Private Server.
Install GIT
You need to install the GIT software:
sudo yum install git
Setup GIT
Use these commands and replace them with your username and email address
git config –global user.name “xx”
git config –global user.email “xx@email.com”
git init
Add ssh keys to Bitbucket
To be able to push and pull from Bitbucket, you need to setup the ssh keys. Set this up on the VPS and then Bitbucket
Generate the key using SSH on the VPS
ssh-keygen
take all default
ls ~/.ssh
vi ~/.ssh/id_rsa.pub
Then in Bitbucket click on your Personal profile and then Bitbucket settings:
Click on SSH keys
Click on Add Keys that was previously generated from the VPS
Add changed files to the repository
Issue the command
git add –all
If you just want to add several files check first of all the files that have changed by using
git status
Commit
If you want to add your list of file changes to the repository then you need to commit and add a name
git commit -m “Initial Commit”
git remote add origin git@bitbucket.org:[project name]
git push -u origin master
Delete files
If you need to delete files from the repository use these commands:
git rm -r —cached .
git add .
git commit -m “.gitignore after clearing cache”
git push -u origin master
Git Pull from repository
If you need to download the latest changes from the repository then use
git remote add origin git@bitbucket.org:[project name]
git pull origin master
Now if the developer set up a new branch, then use the correct name.
There are other tools like GitHub but I personally haven’t used it yet.
There’s probably more to learn and will update this post as I go.
Other Useful Commands
git restore [filename] – to stash and restore a modified file
git config –list – this shows the global config list
git remote -v – shows the remote repository
git remove rm origin – removes the git origin
git checkout – changed the head to a particular commit
git checkout . – to checkout all the modified files
git reset –hard xxxx (commit ID) – to rollback to a previous commit
git reset –hard origin/master – force to pull the latest commit
git log – to check the log
git clean -d -f – to remove files on local machine before merging
git config –global –edit – to change the global configuration such as name and email address
git commit –amend –reset-author – to reset the author details before pushing commit to git
git checkout (branch name) -to switch to another branch
git push origin (branch name) – to push to branch
git rm -r –cached [folder] – to remove a folder from local machine e.g. vendor/ in laravel
If you’re using laravel as your framework, then you can use the below commands to update your database changes:
php artisan migrate
php artisan migrate:status
If this article helped you in any way and you want to show your appreciation, I am more than happy to receive donations through PayPal. This will help me maintain and improve this website so I can help more people out there. Thank you for your help.
HELP OTHERS AND SHARE THIS ARTICLE
LEAVE A COMMENT
I am an entrepreneur based in Sydney Australia. I was born in Vietnam, grew up in Italy and currently residing in Australia. I started my first business venture Advertise Me from a random idea and have never looked back since. My passion is in the digital space, affiliate marketing, fitness and I launched several digital products. You will find these on the portfolio page.
I’ve decided to change from a Vegetarian to a Vegan diet and started a website called Veggie Meals.
I started this blog so I could leave a digital footprint of my random thoughts, ideas and life in general.
If any of the articles helped you in any way, please donate. Thank you for your help.
Affiliate Compensated: there are some articles with links to products or services that I may receive a commission.