Created
February 12, 2018 05:21
-
-
Save Abhinay-g/b310d2a8e035da2f470904505784497a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git --version : to get git version | |
====================================================================== | |
git global config variable : | |
git config --global user.name= "User name" | |
git config --global user.email= "EmailID" | |
::::so here config was a git <Verb> | |
to get help : | |
git <verb> --help | |
git hepl <verb> | |
ex : git config --help | |
: git help config | |
:git add --help | |
======================================================================= | |
When you have loacal folder on machine:: | |
$ls -la will return all file in folder | |
now to track all data in folder just hit below command > | |
$git init | |
this will create a .Git file which will contain all data related to Current repository | |
so now if you dont want to track repo then just delete the .git folder using below command | |
$ rm -rf .Git | |
=========================================================================== | |
now we will go for commit our repos (local) | |
but before that ; if we want some file not to get tracked ie no one else can see those file use followiing | |
$touch .gitignore | |
so this command will create a .gitignore file which will contain file to beignored :) | |
now go and simply add file which are not ment for tacking | |
.Project | |
.DS_store : to ignore file .Ds_store | |
*.pyc : to ignore all file with pyc extention | |
================================================================================== | |
Local repos >>Staging Area >>> Online Repos | |
to move file to staging area use command | |
$git add -A : for all Files in folder | |
$git add FileName : for a single file | |
To move file from staging area : | |
$git Reset FileNAme | |
#git Reset : remove all file from staging area | |
To commint with message | |
$git commit -m "Message" | |
===================================================================================== | |
Now we will see who has made commit | |
use command $git log | |
this will display git hash along with user email id | |
=========================================Phase 2 ============================================ | |
Now we have repository online and we have to make it into our local folder | |
Clone online repo to local | |
use $git clone https://git.com/xxxx/xxxx . : clone in same directory | |
$git clone https://git.com/xxxx/xxxx "Path of other directory" | |
------------------------------------------------------------------------------------ | |
To see information about online repos | |
$git remote -v | |
$git branch -a | |
After clone we make some changes in the code in our local repo | |
Now we need to push this changes to online repo | |
Use below command to check the differenece between | |
$git diff : it will show difference between local orignal and current version | |
$git status : it will show that which file is modified | |
Now we will add theses file to staging directory so that we can commit them | |
$git add -a | |
Now commit code locally | |
$git commit -m "Message" | |
Now changes are locally commited , we have to move our changes to online shared Repo | |
but before that we need to check wheather anyone has made change to shared repo code | |
$git pull origin master | |
It will show wheather our repo is upto date | |
If updated then Make the Final commit to Shared online Repo | |
$git push origin master | |
============================================Industrial Usasge================================= | |
Create a branch loacally : ie local Repo | |
$git branch BranchName | |
List branch : Local brances | |
$git branch : this will list all the local branches * is currnet branch | |
Now if you want to wrok on the craeted branch then shoot below command | |
$git Checkout branchName | |
Now make changes | |
Add file to staging area | |
$git Add -a | |
Commit changes locally | |
$git commit -m "Message" | |
So this local commit on local branch has no effect on local master or Remote Repo | |
NOW WE WILL push locally created branch to Remote repo | |
$git push -u origin BranchName | |
now to check our all branches use fullowing code : it will list online and locall brances | |
$git branch -a | |
========================================================================================= | |
now we have moved local branch to remote branch | |
now we want to merge local branch to Local Master | |
So first we will take Master as | |
$git checkout master | |
Now check is there any change in master branch | |
$git pull origin master | |
if someone made any changes to online master then fix it otherwise go ahead | |
Now check which are the branch merged with Master | |
$git branch --merged | |
till now we havent emerged anything to Master | |
USe below command to merge Master | |
$git merge BranchName | |
Now we will push local master to Remote | |
$git push Origin master | |
______________Done :) -------------- | |
Now to check if branch is merged Use below code | |
$git branch --merged | |
Now can delete branch | |
Use below command | |
$git branch -d BranchName : this will delete local branch | |
To delete from online Use below command | |
$git push origin --delete BranchNAme | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment