Github is a distributed version control system which helps to manage the repositories.
These are a list of few commands that you can use frequently on github(git bash)
git help
Take help from github help section for different commands and other errors
git config
To set the basic configurations on github like your name and email.
git config --global user.name "clouddevops"
Sets configuration values for your user name on git.
git config --global user.email clouddevops.cloud@gmail.com
Sets configuration values for your user email on git.
git config --global color.ui true
To see different colours on command line for different outputs.
mkdir store
Create a directory if not created initially.
cd store
To go inside the directory and work upon its contents.
git init
To create a local git repository for us in our store folder.This will help to manage the git commands for that particular repository.
git status
To see whats changed since last commit.It shows all the files that have been added and modified and ready to be commmitted and files which are untracked
git add Readme.txt
To add a file Readme.txt to the staging area to track its changes.
git show
git show is a command used to view information about any git object. git show
git fetch
git commit -m "Created a Readme.txt"
To commit our changes(taking a snapshot) and providing a message to remember for future reference.
git loggit log
git log --oneline--oneline: brief description
git log directory/path/file--graph --decorate: display branching like gitk except for text terminals.
git log --author="name"
git log --graph --decorate --oneline
git gc
git reflog
git reflog --relative-dateCleanup unnecessary files and optimize/compress local repo.
git commit --amend
git commit --amend -m "an updated commit message"
git commit --amend --no-edit
To check the history of commits for our reference.
Different ways to use add command:
Syntax
git add path/filename
Add a file or directory to Git CM control. This does notgit add file1 file2 file3
git add --update
git add .Add all new and changed files to the staging area
git add *Add all new and changed files to the staging area
git add -AAdd all new and changed files to the staging area
git add --allAdd all new and changed files to the staging area
to add series of the file name starting with a or b or c or d like... z (for example some files devops devloper democlass application aws c cpp java javascript jms oracle apps oracle mysql Azure )
here i want add only d , j and o series of the files.
examplegit add d* j* o*
git stage file1
git stage file1 file2 file3 …
git stage .Add all new and changed files to the staging area
git stage *Add all new and changed files to the staging area
git stage --allAdd all new and changed files to the staging area
git stage -AAdd all new and changed files to the staging area
git add
To add a specific list of files to staging area.
To add all files of current directory to staging area.
git add *.txt
To add all text files of the current directory to staging area.
git add docs/*.txt
To add all text files of a particular directory(docs) to staging area.
git add docs/
To add all files in a particular directory(docs) to staging area.
git add "*.txt"
To add text files of entire project to staging area.
More Commands:git pull
git pull merges all the changes present in the remote repository to the local working directory.
git ls-files --stageList files staged.
git ls-files --cachedList cached files.
git ls-files --modifiedList modified files.
git ls-files --othersList other (un-tracked) files.
git ls-files --deletedList deleted files.
git ls-files --unmergedList un-merged files.
git ls-files --killedList killed files that need to be removed due to file/directory conflicts for checkout-index to succeed.
git mv file-old-name file-new-nameRename a file. Moves/renames file.
git remote -vShow URL to origin server.
git rm filenameDelete file from local working index. Don't use the UNIX command rm file-name. Must perform a "git commit" to update the repository.
git rm -r directory/path-r: recursive removal when given a directory name.
git rm -n filenamedry run
git stashAs a consequence, all the changes staged for commit in your current working directory will be saved on the side for later use
git stash save "my_stash_name"In order to create a git stash with a name, use the "save" command and specify the name of your stash.
git stash push -mAlternatively, you can use the "git stash push" command in order to create a stash with a name.
git stash push -m "message" fileTo stash a specific file, use the "git stash push" command and specify the file you want to stash.
git stash --include-untrackedIn order to stash untracked files, add the "-include-untracked" option to your "git stash" initial command. Alternatively, you can simply use the "-u" which is equivalent to the untracked longer version.
git stash -uAlternatively, you can simply use the "-u" which is equivalent to the untracked longer version.
git stash branch branch_nameIn some cases, you may want to stash your current changes into a specific branch.
git stash branch branch_name stash@{stash_index}Let’s say for example that you worked on the "master" branch for modifications, but you decide that your work may need a specific branch for integration. This can be done with the "git stash branch" command.
git stash listIn order to list Git stashes, use the "git stash list" command.
git stash applyIn order to apply your Git stash to your current working directory, use the "git stash apply" command and specify the stash you want to apply.
git stash popTo pop Git stashes, simply use the "git stash pop" command and specify the stash index you want to pop. example:
$ git stash pop stash@{stash_index}
git stash showTo show differences between a stash and the most recent commit, use the "git stash show" command
git stash show -pTo see all the differences including content, add the "-p" option.
git stash dropIn order to drop stashes, you have two options : with drop or clear. If you want to drop a specify stash from your stack, use the drop option and specify the stash index.
git stash clearDrop all stashes using clear If you want to delete all the Git stashes in your stack, you have to use the clear command.
git diffShow difference between stagged and remote repo
git diff directory/path
git diff filename
git diff --staged
git diff --color-words
git diff HEAD ./path/to/file
git diff --cached ./path/to/file
git diff HEAD
git diff branch_1..branch_2Find the difference between two branches of a git repository.
git diff tag_1.._tag_2Get the difference between two tags.
git diff commit_1.._commit_2Get the difference between two commits. To compare commits, we should know the commit hash which we can get using "git log" command.
To figure out what changes you made since last commit.
git fetch origin
git fetch allows users to fetch all objects from the remote repository that don’t currently reside in the local working directory.
git ls-tree HEAD
git ls-tree allows you to view a tree object along with the name, the mode of each item, and the blob’s SHA-1 value. Let’s say you want to see the HEAD, use:
git cat-file –p d670460b4b4aece5915caf5c68d12f560a9fe3e4
git cat-file is used to view the type and the size information of a repository object. Use the -p option along with the object’s SHA-1 value to view the information of a specific object, for example:
git grep "www.clouddevops.in"
git grep lets users search through committed trees, working directory, and staging area for specific phrases and words. To search for www.hostinger.com in all files, use:
gitk
gitk shows the graphical interface for a local repository. Simply run:
git instaweb –httpd=webrick
git instaweb allows you to browse your local repository in the git-web interface. For instance:
git gc
git gc will clean unnecessary files and optimize the local repository.
git archive --format=tar master
git archive lets users create a zip or a tar file containing the constituents of a single repository tree. For instance:
git prune
git prune deletes objects that don’t have any incoming pointers.
git fsck
git fsck performs an integrity check of the git file system and identifies any corrupted objects.
git rebase master
git rebase is used to apply certain changes from one branch to another. For instance:
git reset
git reset command will reset the index and the working directory to the last git commit’s state.
git reset head license
To undo staging of the file that was added in the staging area.
git checkout -license
To Blow away all changes since the last commit of the file.
git commit -a -m "Readme.md"
To add any of our tracked files to staging area and commit them by providing a message to remember.
git reset -soft HEAD^
To undo last commit and bring file to staging area.
git reset -hard HEAD^
To undo last commit and remove file from the staging area as well(In case we went horribly wrong).
git reset -hard HEAD^^
To undo last 2 commits and all changes.
git remote add origin https://github.com/Cloud-Devops-Automation/Maven_Projectgit
This commands make a bookmark which signifies that this particular remote refers to this URL. This remote will be used to pull any content from the directory and push our local content to the global server.
git remote add <address>
To add new remotes to our local repository for a particular git address.
git remove rm
To remove a remote from our local repository.
git push -u origin master
To push all the contents of our local repository that belong to master branch to the server(Global repository).
git clone https://github.com/Cloud-Devops-Automation/Maven_Projectgit
To clone or make a local copy of the global repository in your system (git clone command downloads the repository and creates a remote named as origin which can be checked by command - git remote -v).
git branch Testing
To create a new branch named as Testing.
git branch
To see all the branches present and current branch that we are working on.
git checkout Testing
To switch to branch Testing from master branch.
ls
To see directories and files in the current directory.
git merge Testing
git branch
git branch branchname
git branch -m oldbranchname newbranchname
To merge Testing branch with master branch.
git checkout -b [branch name] origin/[branch name]
To clone a remote branch and switch to it
git push origin -delete [branchName]
To delete a remote branch
git branch -d Testing
git push origin -delete [branch name]To delete a remote branch
To delete Testing branch.
git checkout -b admin
To create a new branch admin and set it as current branch.
git branch -r
To look at all the remote branches.
git branch -D Testing
To forcefully delete a branch without making commmits.
git tag
To see the list of available tags.
git checkout v0.0.1
To set the current tag to v0.0.1.
git tag -a v0.0.3 -m "version 0.0.3"
To create a new tag.
git push -tags
To push the tags to remote repository.
git fetch
To fetch down any changes from global repository to current repository
git rebase
Three tasks are performed by git rebase
- Move all changes to master which are not in origin/master to a temporary area.
- Run all origin master commits.
- Run all commits in the temporary area on top of our master one at a time, so it avoids merge commits.
git revert commit idCreate new commit that undoes all of the changes made in commit, then apply it to the current branch.
/pre>
The DevOps seminar will help you to learn DevOps from scracth to deep knowledge of various DevOps tools such as fallowing List.
  Kubernetes. />