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 bas…


This content originally appeared on DEV Community and was authored by Clarance Liberi ?

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 version
git --version

# - configure you Name and your email to identify yourself with Git
git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Initializing/creating repository

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

# - initializing git repository
git 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 etc
git 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 file
git add file.js

# - staging multiple files
git add file.js file2.js file3.js

# - staging all files
git 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 repository
git 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 history
git 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' branch
git 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 branch
git branch new-branch-name

# - switching to branch in the repository
# - if branch 'branch-name' does not exists 
#   on the repository git will create it
git switch  branch-name

# - switch to any branch in the repository
# - 'master' is the branch we want to switch on
git checkout master


# - list all branch in the repository
git branch

#merge active branch  to branch 'branch-name'
git merge branch-name

# - delete branch
# - 'branch-name' is the branch we are deleting
git 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


This content originally appeared on DEV Community and was authored by Clarance Liberi ?


Print Share Comment Cite Upload Translate Updates
APA

Clarance Liberi ? | Sciencx (2021-03-19T13:13:29+00:00) Quick review on git commands. Retrieved from https://www.scien.cx/2021/03/19/quick-review-on-git-commands/

MLA
" » Quick review on git commands." Clarance Liberi ? | Sciencx - Friday March 19, 2021, https://www.scien.cx/2021/03/19/quick-review-on-git-commands/
HARVARD
Clarance Liberi ? | Sciencx Friday March 19, 2021 » Quick review on git commands., viewed ,<https://www.scien.cx/2021/03/19/quick-review-on-git-commands/>
VANCOUVER
Clarance Liberi ? | Sciencx - » Quick review on git commands. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/19/quick-review-on-git-commands/
CHICAGO
" » Quick review on git commands." Clarance Liberi ? | Sciencx - Accessed . https://www.scien.cx/2021/03/19/quick-review-on-git-commands/
IEEE
" » Quick review on git commands." Clarance Liberi ? | Sciencx [Online]. Available: https://www.scien.cx/2021/03/19/quick-review-on-git-commands/. [Accessed: ]
rf:citation
» Quick review on git commands | Clarance Liberi ? | Sciencx | https://www.scien.cx/2021/03/19/quick-review-on-git-commands/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.