This content originally appeared on DEV Community and was authored by shubham yadav
Git is an example of a distributed version control system commonly used for open source and commercial software development.
Let's go :
- initalize git in files/directories.
git init
2.Clone the repository in your local system.
git clone https://github.com/<your-user-name>/<repo-name>
3.To check the current status of the repository.
git status
4.To add specific file to the staging area.
git add <file-name>
5.To add all changed file to staging area.
git add .
6.To unstage a certain file
git restore --stagged <filename>
7.To see recent changes in the repository.
git diff
8.To give a message and commit.
git commit -m "your-message"
9.To see the commit history.
git log
10.To see last specific commits (eg. Last 3 commits).
git log -3
11.To discard the specific commit.
git revert <commit-token>
12.To undo the commit and bring back changes to staging area.
git reset --soft HEAD <no._of_commit_to_revert>
13.To show remote URLs
git remote -v
14.To fetch the changes from origin to your local system.
git pull origin
15.To create a branch named branch-name.
git branch <branch-name>
16.To make changes in the specific branch.
git checkout <branch-name>
17.To merge sub branch to main branch.
git merge <branch-name>
18.To delete a specific branch.
git branch -d <branch-name>
19.To push the recent commits.
git push origin <branch-name>
This content originally appeared on DEV Community and was authored by shubham yadav
shubham yadav | Sciencx (2021-06-01T07:25:58+00:00) Useful Git Commands.?. Retrieved from https://www.scien.cx/2021/06/01/useful-git-commands-%f0%9f%92%bb/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.