Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 19, 2021 01:13 pm GMT

Quick review on git commands

In this blog we are going to review some basic git commands, we are going to work through all essential git commands that you need to start working with git efficiently and productive

Setting up git

After downloading and installing git bash you will need to set up this information so that git can start working properly but this will only be set once , unless you re-install new git

# - check git versiongit --version# - configure you Name and your email to identify yourself with Gitgit config --global user.name "Your Name"git config --global user.email "[email protected]"

Initializing/creating repository

in case you are creating new repository to track your file changes
you will need to use this command

# - initializing git repositorygit init

Status [ of the repository]

when you want to see the status of the files in the repository, again in the current branch you will use this command which will show untracked files etc

# - show status of the repository# - shows files which have been changed,#   tracked, staged etcgit status

Stagging files

all about adding files to git repository, notice that you can use remove instead of add if you want to unstage files or remove files

# - staging :   adding files to stage area# - staging area :  files that are going to be included #               in next commit# - staging one filegit add file.js# - staging multiple filesgit add file.js file2.js file3.js# - staging all filesgit add .

Committing file [or stagging files]

saving changes you made in the repository.

# - commit : a term used for saving changes#           to a repository# - committing changes made from stagged files# - '-m' means message , a message should be descriptive# - showing what changes really made in the repositorygit commit -m "Commit message"

History [of the repository]

list of necessary commands that you need to work through your git repository history.

# - view your commit historygit log# - revert / go back to certain commit# - '07e239f2f' is a sample commit id that we are#   trying to go back on git checkout 07e239f2f# - going back to the latest commit on #   the 'master' branchgit checkout master

Branches

list of commands that you will work with to interact with branches in the repository

# - Creating new branch# - 'new-branch-name' is the name of the new branchgit branch new-branch-name# - switching to branch in the repository# - if branch 'branch-name' does not exists #   on the repository git will create itgit switch  branch-name# - switch to any branch in the repository# - 'master' is the branch we want to switch ongit checkout master# - list all branch in the repositorygit branch#merge active branch  to branch 'branch-name'git merge branch-name# - delete branch# - 'branch-name' is the branch we are deletinggit branch -d branch-name

Conclusion
All of these commands are super easy to work with as they are easily explained , with them you can start using github or any other tool so that you can now control versions of your system , and I am pretty sure that it is a good note for those who already know git, Thank you


Original Link: https://dev.to/claranceliberi/quick-review-on-git-commands-1eg6

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To