Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 29, 2021 11:26 am GMT

How to use git

GIT - The easiest method (in a summary)

  1. Create a repo on GitHub
  2. Clone that remote repo on local PC
  3. Write/code whatever in that folder (repo you cloned)
  4. Push to remote repo

-----Details-----

So, step 1
--> Create a GitHub account
--> Create new repository
--> public/private (whatever you want)
--> add readme (if you want)
Create repo
Now your repo is created

Step 2 (cloning)
--> go inside your repo and click on the green button (with a download kind of sign and code written on it)
--> that will create a link, copy that link
--> open your folder where you want to keep this folder(repo)
--> right click --> open git bash
--> git clone "theLinkYouCopied"
(Link must be in quotes)
Now cloned, and since you copied from GitHub, git is already initialised in this repo.

Step 3 (that you do yourself, the productivity part) The usual coding, problem-solving stuff

Step 4 pushing to remote repo
And now whenever you feel like, code is complete, or maybe a part of it is complete, you confirm this,
but before this you need to confirm your identity

git config user.name "yourGithubUsername"
git config user.email "yourEmail"
(Whatever is in quotes must be in quotes)

Then you add the changes by

git add fileThatChanged
(file name with extension without quotes)

Example - if I have a file named test.cpp and I want to add this file, then I would write
git add test.cpp

Or if you want to add all changed files, just write

git add .
(that dot is important, meaning everything in this folder)

Now you need to commit to the changes

git commit -m "commit message"

-m for message, and commit message in quotes, this message should be short, compact but convey the changes you did
Ok, now the changes are finalised, you need to push this to your remote repo, Just write

git push

This will ask to confirm your identity, it will open your GitHub with an oAuth request, just give your GitHub credentials there.

Once authenticated, changes will be pushed to your remote origin (GitHub)


Original Link: https://dev.to/m3rashid/using-git-27k4

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