Git Commands

https://education.github.com/git-cheat-sheet-education.pdf

-----------------------------------------------------
* git Configuration :
-----------------------------------------------------
- List all config    -> git config -l
- Set config for username  -> git config --global user.name "vishnu"
- Set config for email     -> git config --global user.email vishnucse@gmail.com
-----------------------------------------------------
* Git postbuffer size and windomemory set
-----------------------------------------------------
 -> git gc --auto --prune=today --aggressive
 -> git repack
 -> git config --global http.postbuffer 524288000
 -> git config --global pack.windowMemory 256m
-----------------------------------------------------
* check and set remote url :
-----------------------------------------------------
 -> git remote -v
 -> git remote add origin https://github.com/vishnu6666/blog.git
-----------------------------------------------------
* Git basic commands
-----------------------------------------------------
- check uncommited file -> git status
- add all file to staging area -> git add .    or  git add --all
- add single file to staging area  -> git add test.php
- reset all file to staging area -> git reset
- reset single file to staging area -> git reset test.php
- Commit all file -> git commit -m "Test commit"
- Push all file -> git push -u origin master

-----------------------------------------------------
* Git Branch create delete edit
-----------------------------------------------------
- check all branch    -> git branch -a
- check remote branch -> git branch -r
- create new branch -> git checkout -b br1   Or  git branch br1
- rename branch -> git branch -m oldbranch newbranch
- Delete branch -> git branch -d br1
- Push to branch -> git push -u origin br1
- remote branch checkout -> git checkout -b br1 origin/br1
- check git graph branch -> git log --graph --oneline

-------------------------------------------------------
* Git Graphical Interfaces
-------------------------------------------------------
- check Graphical Interfaces  ->  gitk --all
- check Graphical Interfaces with do action    ->  git gui

-------------------------------------------------------
basic for satup and check
-------------------------------------------------------
-> git init
-> git config -l
-> git status


Commands Used:
git log =  git history
git log --all --decorate --oneline --graph = commit history graph
git branch (branch-name) = create a branch
git checkout (branch-name) = checkout a branch/move head pointer
git commit -a -m "commit message" = commit all modified and tracked files in on command (bypass separate 'git add' command)
git diff master..SDN = diff between 2 branches
git merge (branch-name) = merge branches (fast-forward and 3-way merges)
git branch --merged = see branches merged into the current branch
git branch -d (branch-name) = delete a branch, only if already merged
git branch -D (branch-name) = delete a branch, including if not already merged (exercise caution here)
git merge --abort = abort a merge during a merge conflict situation
git checkout (commit-hash) = checkout a commit directly, not through a branch, results in a detached HEAD state
git stash = create a stash point
git stash list = list stash points
git stash list -p = list stash points and show diffs per stash
git stash apply = apply most recent stash
git stash pop = apply most recent stash, and remove it from saved stashes
git stash apply (stash reference) = apply a specific stash point
git stash save "(description)" = create a stash point, be more descriptive


---------------------------------------------------------------------------------------------------
git tag -a v1.4 -m 'version 1.4'

Git global setup
git config --global user.name "Vishnu"
git config --global user.email "email@gmail.com"

Create a new repository
git clone https://gitlab.com/Keepler/p-web.git
cd patroitpcs-web
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Push an existing folder
cd existing_folder
git init
git remote add origin https://gitlab.com/Keepler/p-web.git
git add .
git commit -m "Initial commit"
git push -u origin master

Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/Keepler/p.git
git push -u origin --all
git push -u origin --tags

Comments

Popular posts from this blog

API

Encryption and Decryption By PHP

Seeder