Git commands are a distributed version control system for tracking changes in any set of files
Git for configuration commands:
git config --global user.name "name" git config --global user.email "email" git init projectName cd projectName la -al (master) git status mate README.md git remote -v git push -u origin master --tags
Git basics commands:
git status git add . git status git commit -m "add all text file" git push origin master git push
Create local branch on system command:
//list of brach git branch -a //create new branch only git branch branchName //first create branch and Switched in branch git checkout -b branch-name //Switched branch only git checkout Brach_Name //merge two branch git merge BranchName //delete branch local System git branch -d BranchName //delete branch both location local and github git push origin --delete BranchName //push your code on switched branch git push -u origin Brach_Name
Remove file on git command:
git rm file-name ls -l git commit -m "remove file" git status
Push other new brach on github:
git push -u origin branch-name
Clone github repo:
git clone "clone url" ls -l cd "Your clone repo folder" ls -l git remote -v git status git add . git status git commit -m "Here message" git push origin master
See all log:
git log
Exclude a single file
// Exclude a single file git add --all -- ':!path/to/file.txt' // Exclude multiple files git add --all -- ':!path/to/file1.txt' ':!path/to/file2.txt' // Exclude a directory git add --all -- ':!path/to/directory/*'
Git stage commands:
//stages all git add -A //stages new and modified, without deleted git add . //stages modified and deleted , without new git add -u // see file text cat fileName //show modified file text what modified. git diff fileName //see stage area what modified git diff staged //use for unStaged the file git reset fileName
Two types of tags:
Light Weight tag: store only tagName.
Annotated tags: store tagName and message.
// list of tags git tag // Light Weight tag create git tag TagName BranchName // Annotated tags using -a git tag -a TagName -m "Message of tag" //delete the tag git tag -d TagName // update one tag on github only git push origin TagName //if the tag is already in GitHub page then its create new and replace old. git push --force origin TagName //update all tags on GitHub git push --tags
For more info click on URL.