Hi 👋 , I'm Bhavin!
-
🌱 currently I'mlearning
-
🥅 2021 Goal: Contribute to Open Source stuff -
👯 I’m looking to collaborate on JS project -
📪 How to reach me:[email protected]
In this Blog i'll cover some basic commands of git, using that command you can easily work with git and Github as beginner.
Git
and Github
are not same. many people are understandably confused😕 between this two words at their beginning.To use git we'll need to download and install git on our system by using git. There are both options are available in market. command-line interface(CLI) and graphical user interface(GUI) as Github desktop but I recommend CLI for beginners.
After installation to check if git was installed properly or not execute the command:
git --version
git config --global user.name "<User-Name>"
git config --global user.email <Email>
git init
.git
folder in current directory. this is the "repository"(or repo) where git stores all of its internal tracking data. Any changes you make to any files within the original folder will now be possible to track.The staging area (aka index) is a container where git collects all changes which will be part of the next commit.
git add <File1 path> <File2 path>...
git add README.md app/*.txt
we also stage all changes together
git add -A
OR
git add .
git staus
The "commit" command is used to save your changes to the local repository. we also need commit message it is important to help other people understand what was changed and why you changed it.
git commit -m " <Commit message> "
The git push
command is used to upload local repository content to a remote repository.
git remote add <remote_name> <remote_repo_url>
git remote add origin https://github.com/bhavinvirani/my_repo.git
after creatig a repository on the GitHub, You will find the link on that repository itself
Now, we can push our data on remote repository using this command
git push <remote_name> <remote_branch_name>
git push -u origin master
git push
git init
// make same changes in working directory
git add -A
git commit -m "made some changes in working directory"
git remote add origin https://github.com/bhavinvirani/my_repo.git
git push origin master
In this blog we learned basic command of git and how to push our local repository to remote repository, It is good to use git and github daily to track our code or data.
Stay tuned for some advanced git commands and topics like branches and operations with remote repository which I cover in next article of this series
learning
[email protected]