Git is an open-source version control system and a command-line tool, it is used by programmers, developers, and designers to store projects and keep track of changes to their files. github.com is the website where developers can store their projects. Some basic git command is mentioned below:
git clone /path/to/repositoryThis command is used to clone the application in local repository. Create a working copy of a local repository.
git initCreate a new local repository.
git addThis command used to Add all the files to staging.
git commit -m “Commit message”Commit changes to head (but not yet to the remote repository).
git config –global user.name “jyoti” / git config –global user.email “[email protected]”Configure the user name and email address to be used with your commits.
git remote -vList all the currently configured remote repositories
git push originSend the committed changes to the branch of your remote repository.
git statusList the files you have changed and those you still need to add or commit.
git remote add originIf you have not connected to your local repository to a remote server, add the server to be able to push the code.
git remote -vList all currently configured remote repositories.
git checkoutSwitch from one branch to another.
git checkout -bCreate a new branch and switch to it.
git branchList all the branches in your repository, and also tell you on which branch you are currently in.
git branch -dDelete the feature branch.
git push –all originPush all branches to your remote repository.
git pullFetch and merge changes on the remote server to your working directory.
git mergeTo merge a different branch into your active branch.
git diffPreview changes in all the files whatever you have done.
git diff –basePreview changes for a specific file done by you.
git addAfter you have manually resolved any conflicts, you can mark the changed file then pushed.
git logDisplay all the commits with commitId that is pushed to the remote server, and CommitId will be unique for every commit.
git checkout —With this command, we can undo local changes for that specific file.
git stashSuppose you want to switch to another branch but you don’t want to commit what you have been working on yet, then you can stash the changes using above command.
git stash applyYou can reapply the changes to any branch that you have stashed by using the above command.
git stash clearYou can clear the stash using the above command.
git diff > patch_name.patchThis command used to create a patch with diff output (all the changes that you have done for all the files)
git diffCreate a patch for a specific file.patch_name.patch
git apply patch_name.patchThis command used to apply the patch file changes in your current branch.
git cherry-pickCherry picking is used to choose a commit from one branch and apply it onto another.
git reset –soft HEAD~1Undo the last commit.
git reset –softUndo any previous commit.
git cleanRemove untracked files from the working branch.
git clean -f -dThis command used to remove directories, untracked files from the working branch.
git reflogIt Manage reflog information means it keep record when the tips of branches and other references were updated in the local repository.
Subscribe For Latest Updates
Related Posts