http://www.technicalpage.net/search/label/SQL

git_github

This course is still in Progress, this can be taken as a reference though.

git and github:

Install and Configure Git
Download Git from internet such as from : https://git-scm.com/downloads
You can download for Mac , Window or Linux
Once Git (.exe)is downloaded, run the file
Go through the installation steps and complete it.
Note: while installing , in Adjusting your PATH environment , if you choose : “Use Git and optional UNIX tools from the windows command prompt” , it will allows to use unix commands as well as window commands from command prompt. I would prefer this option.
After installation is complete: you get a bash tool or command prompt. You can write commands in Git bash tool  or command prompt.
Go to your folder from CMD (in window) or BASH tool or Terminal(in apple).
Bash tool can be used as unix command line.
Type git –version  --- to check the installation
Type git  help config --- to check the git help commands
Create a directory, go inside the directory from command prompt then:
Type git init and hit enter--- to initialize the folder/local repository
Note : cd /c  --- this will change the dir to c
Once the local repository is initialized, you can see a .git folder in it which is hidden folder.
Create a dummy file inside the dir and check with git status --- This will show the new file with red color.
Type Git add <file or files> and hit enter ---- to add file to staging area. To add all the files inside the folder:  git add . or git add --all and hit enter.
Type git status and hit enter --- to check the status of the staging area, it shows the file ready to be committed from the staging area.
Type git commit -m "type comment"  and hit enter --- the file or files in the staging area is committed and available in the local repository
Type git push origin master  and hit enter --- to push the local repository to remote/online repository(Github or bitbucket)
Type git pull and hit enter--- to pull the updates from the remote repository to local repository
Type git clone and hit enter---to copy or download the remote repository to local repository
Type git –version and hit enter --- shows the git version
Go to the desired folder and
To add name and email address to git
git config –global user.name ‘Ramhari’ hit enter
git config –global user.email  ‘email@gmail.com’ hit enter
To add a file to git repository:
Git add filename.txt  and hit enter --- this put the file to staging area. Something in the staging area means it is ready to be commit.
To check the staging area status :
Git status   hit enter
To remove from staging area:
Git  rm  -- cached filename.txt  and hit enter
Git rm –cached *.log and hit enter
To add files with certain extension or to add all files:
Git add  *.txt    //with extension txt
Git add  .   // all files
Once you make change to any file , you need to git add thatFile first to add to staging area.
To commit:
The command is
Git commit –m ‘comment for this commit’  and hit enter
BUT what happens when you click git commit only:
You get a window, type i , which is insert mode
Now type initial commit without comment symbol(#) and click escape which brings it out of insert mode and type :wq and hit enter.
The file in the staging area is committed.
Check status : git status ---- this will show no file in the staging area.

Let’s edit the committed file.
Check status : git status ---- this will show the modified file in the staging area.
To commit : Before commit you have to ---git add filename
Then
Git commit –m ‘File 1 is modified at second line’  hit enter.
When you do git  add .  or add  *.doc   it will add all matching files.
To ignore certain file: create a .gitignore  file.
And write the name of the file, to be ignored, in the .ignore file , write file name with extension.
Then it will ignore the file when you use git add . or git add *.extension
You can add whole folder to staging area
Create a folder and type git add . ---- everything including folder will be added to staging area.
To ignore folder while adding to staging area:
Add the folder name in the .ignore file like /FolderName save it
Now, git add . will not include this folder and the files inside it.
To ignore all xls files, in the .ignore file type *.xls and save
To remove directory from git staging:
Git rm –r  --cached dirName/
Clear git staging area -----
Remove folder from staging area ----
See the committed files-----
Remove the committed files from local repository ----

Link git to github account
Command:
Git config  --global  user.name   “githubUserName”   hit Enter

Give email id, it is not mandatory though::
Git congig  --global  user.email   email@gmail.com     hit enter   Note: email is not inside double quote.

Copy the link of remote repository which is available on the text box SSH or HTTPS
Now go back to cmd window and link the remote and local repository
For that :
Git remote add  origin   <paste link here>  hit enter

Push local files to remote repository
Git push origin master     hit enter

To create github account , go to github.com
Give userid, pwd and email and click sign up
After account is created, sign in to it.
Click new repository button
Give the name of the repository
You can give description, which is optional
Select public or private
Check box for initialize the repository with a README
You can select the programming language at Add gitignore
Click Create Repository button
The repository is created.



To clone the remote repository with out initializing the local repository.
Note: git init has not done in this and no need.
Just go inside the local directory in command prompt and do below steps:
Git clone  pasteTheLinkCopiedFromGitAccount   hit enter
This is create a new folder in your local repository with all the files in the remote directory. 
Add a new file to this folder.
To upload this file to remote repository,
Git add filename   hit enter
Git status
Git commit  -m   ‘new file pushing to remote’   filename    hit enter
Git  push    -u  origin   master   hit enter
Enter user id and password in the pop up
Now, the file is available in remote repository.
 

TO CREATE BRANCH
git branch branchName

to switch to the branch
git checkout branchName

Now whatever activity you do , will be in the branch
git add .
git commit -m 'commnet'

Now to switch back to the master
got checkout master

to merge, suppose you are in the master
then
git merge branchName
hit i
enter comment  , press esc
:wq  hit enter

REMOTE REPOSITORY
go to github.com
sign in
Click Create New
New Repository
Enter Repo name and Description
Enter Public or Private
Click Create Repository

You get instruction with commads
You can follow/use the commands to initialize git in your system to linking with github

git remote --- this will show none as you have not added the remote repo
copy the git remote link
paste in the command prompt and hit enter
Now type
git remote -- it shows the result this time 'origin'

click
git push -u origin master , if a pop up appears, enter your id/pwd

all local contents are pushed to github

you can add REAMME.md
Just type something inside it
if you want to add comment then use #

git add .
git commit -m 'added Readme'
git push

refresh the remote repository, you will she Readme with comment and text

To Pull
git pull

To CLONE
copy the clone URL from git hub or download zip file
go to the folder
git clone copiedURL


git init
git add --all
git commit -m "initial commit"
git remote add origin URL
git push -u origin master
git remote remove origin
git remote add origin URL https://UID:PWD@www.google.com/
git push -u origin master

git reset HEAD --->to remove all files from staging area
git reset HEAD <filename> ---> to remove particular file from staging area
git branch --show-current  ---> to see the current working branch
git checkout Branch1---> to switch to the Branch1
git checkout master ---> to switch back to master

To Pull
Get the URL of the git repository
git pull URL

Go and make change in the pulled files.
git status ----> this will show the changed files in staging area
git add .
git commit -m "changed in file xyz.txt"
git status ---> this will show nothing in the staging area
git remote add origin URL
git remote -v ---> to see the fetch and push command
git push -u origin master

No comments:

Post a Comment