#git

Delete a commit from branch in Git

I sure that there is at least once time in the life of a programmer, they need to delete a commit in the history of a branch. So I write this post to share you the way to delete a commit from branch in Git.

My example is we have a git log tree as below:

And you are working on branh DEV, you need to remote “Commit C” from branch DEV. So you should use command git rebase -i

In there, “ea61baa” is the hash key of “Commit C”. After entering the command, a editor will be opened with the content below:

You have to remove line

After that, save it.

You are done, just re-check by git log command

You can see that “Commit C” now is not in branch dev.

What management tools we should use for a start-up business?

As guy who had over 3 years work in quite many start-up companies. I understand that management tools is a very important thing that managers should take time to think about it, and answer all questions as “What management tools we should use?, how to assign tasks? how to track tasks?, how to review tasks? and how to manage workflow? … etc …”. Because, It is easy to know that if your company size is 2-6 employee, it seems that without management tools and workflow, you are still able to operate company only with email, Skype or face-to-face. However, if you had a plan to grow up your business, you should think about management tools and workflow that will be help you operate your company efficiently.

Sometimes the hardest thing and the right thing are the same

Sometimes the hardest thing and the right thing are the same

The below is my suggestion that I have ever used in my works

Gmail

Perfect email solution for small, medium business. Actually, if you have ever used Gmail, you will realize that no other one is better. Additional, Gmail supports company domain (e.g: [email protected]). And used Gmail, you will be used the other wonderful products of Google as Google Driver, Google Calender. Fortunately, you do not have  to pay too much for business. Google Price is so suitable.

Google Driver

Actually, It seems impossible to fully replace Microsoft Office by other one. Google Driver contains in its inside biggest concepts is cloud-computing and social network.  It is so easy for you to sharing or many people who locate anywhere  to compose a document at the same time together.  Better that you thought, Google Driver is making communication faster, the world is being flatter and warmer. Google Driver supports you free 1.5 Gigabyte capacity. If you need more, you should pay money. No worries, Google price is very reasonable.

Google Calendar

Booking room, meeting, conference have never easier. You just need to choose time,  address, description, add people, and click to create your calendar. Google will be notify the participant via email and SMS immediately to confirm the attendant. And they are reminded when it is due. Google Calendar is 100% free.

Asana, Jira or Trello

If you need a system that you could create a task, assign to members and track when it is done. Then Jira or Asana can help you. Asana is younger than JIRA. So you will feel comfortable the user experiences of Asana. However, JIRA support many APIs that you can use to integrate to many other systems.

Slack, Hipchat & Skype

Chatting help you can contact other person instantly.  Skype is good choice. But a software company should use Hipchat that is easy to integrate with other system like Jira, Git.

GitLab, Github (github.com) or Bitbucket (bitbucket.org)

If your company works in software industry. Then source version control is very important thing. You can use SVN, but my suggestion is GIT.  Github and Bitbucket work basing on GIT with web interface.  Those make you feel easy when working with branch, commit, tags, fork, code review.

 

GIT – Keep files when merge conflict

With Git, sometimes you need merge between branches.  For example, you need merge BranchB to BranchA. Almost cases, if it has conflicts, you will open the conflict file and merge it manually. But in some cases, you have to keep file at either BranchA or BranchB. Fortunatly, “git checkout” command with options will help you do that.

To merge between 2 local branches:

Or merge a remote branch to a local branch:

To keep the file that we own:

To keep the file that they own:

In case you have too many files conflicted, you can use the command below:

 

Writing shell script to deploy changed file via ftp

When you work with a cheap host, you just have FTP account to push your file to host. It will be terrible if you have to pull all changed file to host via FTP. Because you must answer many stupid question as “what files I was change?”, “Where files I was change?”, “What is ftp account?” …

0284ed8e-26be-11e4-a4aa-12313d044945-medium

So I think that it is better if you write a script to handle all task and help you answer all question. The way is posted the below will run well in linux environment.

Firstly, we need a script to upload file via FTP.  The script below requires CURL. You just need to change value of REMOTE_HOST, REMOTE_USER, REMOTE_PASSWD. It will work well.

After that, you write a script to list all file that needs to push to your FTP host. That script is similar to the script below.

With the script above, you need to provide 2 tag name, and script will check all file changes between them.  Finally, It calls fpt.sh script to push that files to FTP host.

You can see full source code in my Github: https://github.com/thanhson1085/git2ftp

Working with branch in GIT

A strong point in GIT is so flexible when working with branch. So now I will share some GIT commands that usually use when working with branch.

e5191b66-3127-11e4-a844-22000a98b2af-medium

You never know how strong you are until being strong is the ONLY option you have

 

In software development process, when your production was go live, you should create new branch for each issue. And after finishing a issue you should merge code carefully.

List all branch of repository (both local and remote)

Checkout code from a remote branch

Update code from all remote branch

Merge code between two branch

Merge specify commit to branch:

Create branch from previous comit

Checkout specify file from other branch:

 

How to GIT

As you know, with GIT,  you can setup a social network for developer. Everyone in everywhere can code your project, as long as they know how to use git.

How to push your change to remote

How to create new branch in local

How to switch branch

How to create new branch in remote

How to delete branch in local

How to delete branch in remote

How to merge 2 branches in remote

 

How to revert changes before add

How to remove file in remote

How to remove folder in remote

 

How to show git history

How to ‘undo’ git commit

How to ‘undo’ git add

How to ‘undo’ git push

How to add a tag

How to delete a tag in local

How to push a tag to remote

 

How to checkout to tag

How to delete a tag in remote

How to checkout a remote branch

How to edit a commit message

How to revert changes in local

How to list of file changes

How to pull a git branch from remote

How to ignore file locally

Move a tag