Thursday, December 5, 2019

GIT

Create a sample.txt file Sample Folder.
In sample folder directory run command prompt
Run git init to initialise git in the directory

git init - working directory - git add - staging area - git commit - repository

Now track the text file with git add sample.txt to track the file.
Tracked file changes can be seen with git diff sample.txt
Differences are prefixed with + symbol


Now add the changes to staging are with git add sample.txt
Commit is the final step. Message is added along with a commit (50 Characters)
git commit -m "First Commit" command is used to staged files.
Commit logs can be seen with git log command.

Why Branch?
To have multiple version. (Happy ending, Sad Ending).
 




  • git init creates a new Git repository
  • git status inspects the contents of the working directory and staging area
  • git add adds files from the working directory to the staging area
  • git diff shows the difference between the working directory and the staging area
  • git commit permanently stores file changes from the staging area in the repository
  • git log shows a list of all previous commits

  • git checkout HEAD filename: Discards changes in the working directory.
  • git reset HEAD filename: Unstages file changes in the staging area.
  • git reset commit_SHA: Resets to a previous commit in your commit history. 
  • git branch: Lists all a Git project’s branches.
  • git branch branch_name: Creates a new branch.
  • git checkout branch_name: Used to switch from one branch to another.
  • git merge branch_name: Used to join file changes from one branch to another.
  • git branch -d branch_name: Deletes the branch specified.


Sunday, August 7, 2016

React Progress

Why use React?

Most popular js framework. Backed by Facebook. Has easier learning curve than angular. You need NPM to run them on your machine.

How to Install React?

Type the following command in command prompt
npm i -g create-react-app
Here i stands for install. Now type
create-react-app [appname]  (capital letter is not allowed).

How to run React?
Use cd [appname] to go in the folder. Type npm start  to run the react application.

How to install bootstrap on your App?
In terminal (on the directory) run the code npm i bootstrap 
Import them in index.js by adding import 'bootstrap/dist/css/bootstrap.css';

React Component:
React component can return only one element. Wrap child elements with parent a parent element.
Use React.Fragment to append without a parent div.
Return should only have html and {expression} JSX expression. Methods must be declared before or after the render()
Create your components in components folder under src folder. Don't forget to import the component in index.js
  
State:
Use {} to encapsulate javascript expression. State is used to store variables for a component. 
state = {
 name: 'Ashwin'
}
Use the state object by this.state.name expression within the return ();

Changes in markup:
class = className
Direct styling is not possible, declare styles for an element as property and inherit it in as JSX expression.

style = {
 fontWeight : 'bold'
}
<h1 style = {this.style}>Hello World!</h1> 

OR

<h1 style = {{ fontWeight: 'bold' }}> Hello World!</h1>

Rendering an array:
define the array as a property
state = {
   arraySamp : ['one','two', 'three']
}
Use the following code to render the array in JSX
<ul>{this.state.arraySamp.map(arrayS => <li key={arrayS}>{arrayS}</li>)}</ul>
 



 
  

Search This Blog

Powered by Blogger.

GIT

Create a sample.txt file Sample Folder. In sample folder directory run command prompt Run git init to initialise git in the directory g...