Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vijaydeepak-tt/35c94b41ce957acf238b92e1b154f54e to your computer and use it in GitHub Desktop.
Save vijaydeepak-tt/35c94b41ce957acf238b92e1b154f54e to your computer and use it in GitHub Desktop.
Commands used in the git-bash for development
git(DVCS - Distributed Virsion Control System) - bash cmd's:
git - bash common CMD's:
cd .. --> go back directory.
pwd --> returns the full path of the repository.
clear --> clears the bash.
ls --> returns the list of files and folders which are in visible.
ls -al --> returns all the files and folders in the repository including the hidden.
ls -l --> returns all the files and folders and including innerr files of that folders, in the folder including the hidden.
mv <old-repo-name>/ <new-repo-name> --> renames the folder name.
vi <file-name-with-extention> --> creates the file and edit the content, to quit - ctrl+z.
rm <file-name> --> removes the file.
Configuration CMD's:
git config --global --list --> Returns the list of data's configured for the git.
git config --global user.name "<name>" --> Set's the username.
git config --global user.email "<email-address>" --> Set's the email-address.
git config --global --get <property-to-get> --> returns the value in the property in config if exists.
git config --global --replace-all <property-to-change> "<new-value>" --> replacces the new value to the mentioned propety.
git config --global --unset core.gitproxy --> reset the proxy.
Development CMD's:
git init --> initializes the git repository.
git init <repo-name> --> creates the repo in the given name if not exist, and initializes the git.
git status ---> returns the status of the files whether the files are added or not which are not commited yet.
(staging) git add . --> moves all the newly created and modified files to the staging.
(staging) git add <file-name> --> moves particular file to the staging.
git reset HEAD <file-name-with-extention> --> to unstage. (when file is checked out)
git rm --cached <file-name> --> to unstage the particular file.
git commit -m "<comments-required>" --> commits all the files to the git which are staged.
git checkout -- <file-name-with-extention> --> revertes the commited changes.
git log --> to view all the git commit history with multiline details.
git log --oneline --> to view all the git commit history in single line details.
git log -n <number> --> to views the number count the git commit history with multiline details.
git log --oneline -n <number> --> to views the number count of the git commit history in single line details.
git log <file-name-with-extention> --> returns the log for the particular file.
git remote add origin <repository url> --> adding the remote of project repository link to the local project.
git remote rm <remote-name(ex: origin)> --> removes the remote url.
git remote -v --> to list remote url of that repository.
git remote set-url <remote-name> <new-url> --> change the remote url.
git push -u origin master --> push the code to the master branch.
git pull --> pulls out the latest code from the repository.
git pull --all --> pulls entire origin with all branches.
git fetch --> fetches entire origin with all branches.
git clone <repository url> --> clones the existing project repository.
git branch --> returns the existing branches list.
git branch <branch-name> --> creates a new branch.
git checkout <branch-name> --> switching from one branch to another particular branch. (master to any or any to master or any to any)
git merge <branch-name> --> merges the particular commits to the particular checked out branch.
(EX: if im in master, then it merges to master, if im in test-branch then it merges to test-branch, but no the master)
git merge --squash <branch-name> --> summarises the requested branch commits and merges with to the actual branch.
git branch -d <branch-name> --> deletes the particular branch.
GIT Stash:
git stash --> to take the shelve(or stash) befor commit. saves in the pushed order.
git stash push -m "comments" --> to stash with reference comments.
git stash pop --> to update the latest(last) stashed content into our code and removes from the stash list
git stash pop 0 --> to update the stashed content into our code and removes from the stash list.
git stash apply --> to update the latest(last) stashed content into our code and maintains in the stash list.
git stash apply 0 --> to update the latest(last) stashed content into our code and maintains in the stash list.
git stash list --> returns the list of stashs.
git stash branch --> creates a new branch for you, checks out the commit you were on when you stashed your work,
reapplies your work there, and then drops the stash if it applies successfully.
git rebase <branch-name> --> current branch the latest code from the requested branch. It is done if ther is no conflict.
If there is any conflict occured while rebase, merge the code manually and run "git add/rm ." and run "git rebase --continue" to continue the rebase process.
If there is no need of accep the conflicts run "git rebase --skip" to skip the conflict merge process.
If wish to abourt or come back to the state before "git rebase" run "git rebase --abort"
README.md file Editer syntax:
"#" before charecter makes "h1" size
"##" before charecter makes "h2" size
"**" at the start and ending the word makes it "bold"
"*" space and the word makes the star a "dot"
"*" without space at start and end of the word makes it "italic"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment