アプリ関連ニュース

The essential Git commands

Why you should learn Git?

Git is the most useful version control system. Git tracks the changes you make to files and collaboration easier and allows multiple people to work on the same files at the same time.

For a new or experienced people using Git is full potential and you need to know Git commands. Here you will learn the essential Git commands that will take you from one level to another.

If you are a new developer, start to learn here Basic Git commands to more Advanced Git commands step by step.

In this section, you will learn the essential foundation Git commands.

git config

When you are using Git first-time, you need to customize your Git environment. This command will set up your user name and email address. This is important because every Git commit use this information.

Usage
$ git config --global user.name “Your name”
$ git config --global user.email “Your email”

git version

It’s just to check what Git version you are using.

Usage
$ git version

git init

It creates an empty Git repository for the first command to start a new project in Git. And then you can store your source code inside this repository.

Usage
$ git init

git clone

The git clone command will use when you need to make a copy of an existing Git repository.

Usage
$ git clone <your project URL>

git add

The git add command will add a new file and modified files,  an changes in the working directory to the staging area.

$ git add <your_file_name> (it will add a single file to your staging area)
$ git add * ( it will add all the modified and new files to the staging area)

git commit

This Git commit will add your changes to the local repository.

Here is the usage of the Git commit command.
$ git commit  “your useful commit message”

git status

The git status command displays the state of the working directory and the stating area. It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git.

Usage
$ git status

git branch

The Git branch command lets you to manage your branches effectively like create, list, rename, switch and delete branches.

Usage	
To list all branches
$ git branch

To create a new branch
$ git branch <branch_name>

To delete a branch
$ git branch –d <branch_name>

git checkout

The Git checkout command lets you switch between branches.

Usage
$ git checkout <branch_name>

You can checkout and create branch at the same time with a single command, like that

$ git checkout –b 

git remote

Remote repositories are versions of your project that are hosted on the Internet or network somewhere. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.

Usage
$ git remote add <shortname> <url>

git push

With the help of the git remote command the git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo.

Usage	
$ git push -u <short_name> <your_branch_name>

git fetch

The git fetch command downloads commits, files, and refs from a remote repository into your local repo. Git fetch is a safer alternative because it pulls in all the commits from your remote but doesn’t make any changes to your local files.

Usage 
$ git fetch

git pull

The Git pull command downloads the content and immediately updates your local repository with the latest content.

Usage 
$ git pull <remote_url>

git stash

This Git command temporarily stores your modified files. You can work in stashed with the following Git command. 

Usage 
$ git stash 
you need a apply a stash to a branch, simply use apply 
$ git stash apply

git log

This git log command lets you to review and read a history of everything that happens to a repository.  Generally, the git log is a record of commits.

Usage 
$ git log

git rm

This git rm command lets you to remove files from both the staging index and the working directory.

Usage
$ git rm <your_file_name>

git merge

This git merge command merge two branches you were working on.

Usage
$ git merge <branch_name>

git diff

Diff command is used in git to track the difference between the changes made on a file.

Usage
to compare the working directory with the local repo:
$ git diff HEAD <filename>
to compare two branches
$ git diff <source branch> <target branch>

git mv

This git mv command lets you to move files or directories from one place to another . It supports moving single files, multiple files and directories. 

Usage
$ git mv <old-file-name> <new-file-name>

By Ami



DB管理をAdminerでおこなう

PHPのSQLマネージメントツールとしてはphpMyAdminが有名ですが、類似のツールとして「Adminer」があります。
今回は「Adminer」を紹介したいと思います。

続きを読む

個人用ファイルサーバー機の作成(HDDの組み込み)

ゴールデンウィーク前に発注していたハードディスク8台が届いたので、ファイルサーバー機用に組んでいたPCに組み込みました。

続きを読む

Basic Auth by PHP

There are several ways to add a basic authentication using php. Today I would like to share a snippet to add basic authentication easily.

Lets get started.

<?php

//you can define your custom username and password here.
$AUTH_USER = 'username';
$AUTH_PASS = 'password';

header('Cache-Control: no-cache, must-revalidate, max-age=0');
$credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));

//check credentials existence or wrong credentials
$auth_fail = (
	!$credentials ||
	$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
	$_SERVER['PHP_AUTH_PW']   != $AUTH_PASS
);

//Ask for the auth. If credentials are not correct, deny the access.
if ($auth_fail) {
	header('HTTP/1.1 401 Authorization Required');
	header('WWW-Authenticate: Basic realm="Access denied"');
	exit;
}

After the coding process, you will get a confirmation alert box for authentication before accessing the website as below.

Well, I think you can now add basic auth in any of your PHP application neat and easily.

If you want to add basic authentication for contents like html and images etc , you can also do that by configuring .htaccess

Yuuma



Visual Studio Code for PHP developers

Makes it clean and pretty code each time you open VS Code to help us all become better engineers! I want to share some important VS Code tips and tricks.

Quickly open files
Keyboard Shortcut:  Ctrl+P

Access all available commands.
Keyboard Shortcut: Ctrl+Shit+P

Navigate between recently opened folders and workspace
Keyboard Shortcut: Ctrl+R

There are many things you can do to customize your code format.

  • Change your theme

Firstly Keyword Shortcut: Ctrl+Shit+P then go to type >theme and select your preference theme.

If you want to add color theme, I recommend Gruvbox Material. It’s totally pretty color theme that I’ve used.

Customize your keyboard shortcuts
Keyboard Shortcut: Ctrl+K Ctrl+S

Search and Install extensions
Keyboard Shortcuts : Ctrl+Shift+X
You can find extensions in the VS Code Marketpalce.

Integrated Terminal
Keyboard Shortcut: Ctrl+`

Toggle SideBar
Keyboard Shordcut: Ctrl+B

Toggle Panel
Keyboard Shordcut: Ctrl+J

Zen mode
Keyboard Shortcut: Ctrl+K Z
Press Esc twice to exit Zen mode.

Move to Explorer window
Keyboard Shortcut: Ctrl+Shit +E

Navigation entire history
Keyboard Shordcut: Ctrl+Tab

Multi Cursor selection
Keyboard Shortcut: Ctrl+Shit+Left

To set cursors above or below the current position use
Keyboard Shortcut: Ctrl+Alt+Up or Ctrl+Alt+Down

Copy line up / down
Keyboard Shortcut: Shift+Alt+Up or Shift+Alt+Down

Code Formatting
Whole document format: Shift+Alt+F

Code Folding
Keyboard Shortcut: Ctrl+Shift+[ or Ctrl+Shift+]

Select Current Line
Keyboard Shortcut: Ctrl+L

Navigate to beginning and end of file
Keyboard Shortcut: Ctrl+Home and Ctrl+End

Move line up and down
Keyboard Shortcut: Alt+Up or Alt+Down

Git integration

Keyboard Shortcut:  Ctrl+Shift+G

You can install other SCM providers from the Extension Marketplace. Most of the time I’m preferred GitLens extension. It’s incredible useful.

Diffs

From the Source Control view, select a file to open the diff.

Views

The default view for diffs is the side by side view.

Toggle inline view by clicking the More Actions (…) button in the top right and selecting Toggle Inline View.

Branches

Easily switch between Git branches via the Status Bar.

Staging

Hover over the number of files and click the plus button.
Click the minus button to unstage changes.

Undo Last Commit

Click the (…) button and then select Undo Last Commit to undo the previous commit. The changes are added to the Staged Changes section.

See Git output

VS Code makes it easy to see what Git commands are actually running. This is helpful when learning Git or debugging a difficult source control issue

Use the Toggle Output command (Ctrl+Shift+U) and select Git in the dropdown.

By Ami



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム