GitHub is a Web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.
Unlike Git, which is strictly a command-line tool, GitHub provides a Web-based graphical interface and desktop as well as mobile integration. It also provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.
Source : Github Wiki
Terms and Definitions.
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
To create a new Branch
git checkout -b "branch_name" // creates branch and sets new branch as working branch
or
git pull github master
Unlike Git, which is strictly a command-line tool, GitHub provides a Web-based graphical interface and desktop as well as mobile integration. It also provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.
Source : Github Wiki
Terms and Definitions.
SNAPSHOT/COMMIT
It commits a snapshot that you can refer back to.
CACHE(INDEX / STAGING AREA)
Place where all the active files are placed , monitored before committing
Git Repository
Located in local folder staging , any folder/dir when initialized becomes git repository.
Create pair of Public / Private Keys
To check our public key works
After Adding public key to github SSH Keys
ssh -T git@github.com
Configure Git
git config --global user.name "Name"
git config --global user.email "Email@domain"
To check the config
git config --list
Now let's create a directory
mkdir gitproject // master branch for our project
cd gitproject
vim readme.txt
vim test.txt
git status // tells what branch you are in , what files have changed, what files are tracked , hints on what to do next.
Now let's add the files to staging are
git add . // shortcut to add all the files in present directory
git rm --cached <filename> // to remove file from staging area
git commit -m "message for commit"
git log // check the commit log
git diff // check the difference of updated file before adding to the staged area
git diff --cached //check the diff after adding to staged area
git log --oneline //only commit messages
git commit -a -m "message" // adding files to staged area and committing in one line
git status -s // short status
Create a new repository on GitHub and copy the link
Eg(https://github.com/viprai91/SampleTutorial.git)
To push an existing repository to github
Eg(https://github.com/viprai91/SampleTutorial.git)
To push an existing repository to github
git remote add origin "name of remote repo"
(Eg : git remote add origin https://github.com/viprai91/SampleTutorial.git)
(Eg : git remote add origin https://github.com/viprai91/SampleTutorial.git)
git push origin master
// origin is the name we gave in above step , master is the parent directory , also once added to remote , use the same command to push the changes
// origin is the name we gave in above step , master is the parent directory , also once added to remote , use the same command to push the changes
Branching - Allows to create a separate working copy of code
Merging - Allows to merge branches together
Cloning - Other developers can get copy of code.
Branching -
git branch // tells all the branches available for the repository
To create a new Branch
git checkout -b "branch_name" // creates branch and sets new branch as working branch
or
git branch "name" // creates branch with the name
eg: git branch r2_index
to change the branch (Note the current branch will have * before the name)
git checkout r2_index
// Switched to branch 'r2_index'
// to clone the same repo for other dev on diff computer use clone
git clone sshlink
Merge
// to merge changes from branches to master
git merge master // when we are in r2_index and need to merge to master
Pull
Pull syncs local repository with remote repo
git pull github master
Note: Always pull before push, so that we have the latest version of the code which might have been edited by someone else.

No comments:
Post a Comment