git init
-> Initializes git in any folder/repository (Needs only if you are not cloning a repository)git clone https://github.com/<your-user-name>/<repo-name>
-> Clones the repository in your local system.git status
-> Shows the current status of the repository.git add <file-name>
-> Adds specific file to staging areagit diff / git whatchanged
-> Gives the recent changes in the repositorygit add .
-> Adds all changed files to staging areagit commit -m "<your-message>"
-> Gives a message to your current files and takes their snapshot to commit historygit log
-> Shows the commit historygit revert <commit-token>
-> Discards the specific commit (Deletes the committed files but keeps a trace in history)git reset --soft HEAD~<no-of-commits-to-revert>
-> Undo's the commit and brings the changes back in the staging areagit restore --staged <file>
-> Brings back the specific file in the changes made section which is added to the staging area.git remote -v
-> Shows all the remote connectiongit remote add origin https://github.com/<your-user-name>/<repo-name>
-> adds your forked branch as the origin (No need to do if the repo is cloned)git remote add upstream https://github.com/<parent-user-name>/<repo-name>
-> Adds parent repository as upstream.git pull origin
-> fetches the changes made in origin to your local systemgit pull upstream
-> fetches the changes made in origin to your local systemgit branch <branch-name>
-> Creates a branch with branch-namegit checkout <branch-name>
-> This now allows you to make changes in the specified branchgit checkout -b <branch-name>
-> This is combination ofgit branch <branch-name>
andgit checkout <branch-name>
git merge <branch-name>
-> merges its children branch-name into its parent branch.git branch -d <branch-name>
-> Deletes the specified branch. And if the changes in the branch-name are not merged in the parent branch then the changes are deleted.git push origin <branch-name>
-> Pushes the recent commits to the new branch
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (10)
@kaiwalyakoparkar , thank you for your post.
I did not find also few commands but found the source :)
For everyone who want to find more information please use the link:
business-science.github.io/shiny-p...
My current project at work requires a lot of little changes to build locally, changes which I can't push up to master.
My workaround is to create a branch with one commit containing those changes, git cherry-pick it into my current working environment, then git rebase -i to remove it from the changes I'm going to push.
Thanks for that information. I will do quick research on that commands and will sooner add them....π
I am missing here:
git rebase
andgit reflog
..Thanks for the reply. I will add it soon!
<3 this
It helped me a lot Thank You π
Glad to hear that!
I think one git stash and git stash pop are also one of the most important commands.
Yup, they are indeed but they are used occasionally when you have to save the changes temporarily somewhere else. This blog was aimed to provide a cheat sheet to the beginners and intermidiates. I am planning to write about these commands in the next blog. so stay tuned :)