Git Full PDF
Git Full PDF
Repository : GIT Repo is a directory that stores all the files, folders and
content needed for your project
Branch : A version of the repo that diverges from the main working project.
Branches can be a new version of a repository
Master : the primary branch of all repo’s. All committed and accepted
changes should be on the master branch.
Step 2 : Configuration
#git config --global user.name rajeshdevops ------ configuring user name
#git config --global user.email [email protected] --- configuring mail id (master mail id)
#cat .gitconfig (or) #git config --list
#echo “Welcome to GIT” >> README.md --- creating README.md file and writing “Welcome to GIT” in it
#git status ---- it show git status as what are changes done on branch
#git status
#git commit -m “<comments>” ------- to move all changes from stage area to local repo
#git commit -a -m “<comments>” ----- to add to cache and commit to local repo at a time
#git log -p ---- to show all git commits with code changes
#git log --oneline ---> to show logs in one line with commit id
#git log --since=01-01-2019 --until=08-01-2019 ---> to show logs between
dates
To work with Branches : always branch will be created from latest commit ID only
#git branch ---> to list all branches
#git branch <branch name> ---> to create branch
#git checkout <branch name> ---> to change / switch branch from current branch
#vi index.html ---> adding file in <branch name> branch
#git commit -a -m “index.html added”
#git push origin <branch name>
Check in browser git hub
#git rm <file name> ---> to remove file name which are associated with git
#git log <file name> ---> to show all logs related to file
#git diff 33eeee ..345dddd ---> to show difference between two commits
#git tag <tag name> <commit id> ---> creating tag name for commit id
#git diff <tag name> <tag name> ----> to show difference between tag
#git checkout master ----> to change from current branch to master branch
#git merge <branch name> ---> to merge <branch name> to master branch
#git push -u origin master ----> to push merge to central repo
#git branch -d <branch name> ---> to delete a branch from local repo only
#git branch -D <branch name> ---> to delete a branch from local without merging
#git push origin --delete <branch name> ---> to delete branch from central (check in web)
Merge : Merge takes all the changes in one branch and merges them into another
branch in one commit
Git Rebase : as its name suggests, rebase exists to change the “base” of a
branch, which means its origin commit.