git config:
Now that git is installed, you have to tell it who you are. Or more exactly, what name it should display when you write changes in the database. (Git will not check anything so it can be pseudonyms). You just need to tell Git the name and email you want to appear next to your records. To do this we will use the git config command. To specify the user name for the whole working environment (whichever folder you’re working on), you have to type the following (whilst adapting it to your case)
git config --global user.name “[name]”
git config --global user.email “[email address]”
# ---- to check that your emailand username is set do
git config --list
# --- you should get something like this
credential.helper=osxkeychain
init.defaultbranch=main
user.name=*** ***
user.email=********@gmail.com
http.postbuffer=157286400
END
This command sets the author name and email address respectively to be used with your commits.
git init -b main
Initializing the folder to be a Git repo.
if all went well you should see:
Initialized empty Git repository in /TestRepository/.git/
# To confirm that we can do
ls -la
# It should return a list of files in that directory along with a folder called ".git"
Usage: git init
This command is used to start a new repository.
git clone
Usage: git clone [url]
This command is used to obtain a repository from an existing URL.
git add .
Usage: git add [file]
This command adds one or more files to the staging area.
git commit
Usage: git commit -m “[ Type in the commit message]”
This command records or snapshots the file permanently in the version history.
Usage: git commit -a
This command commits any files you’ve added with the git add command and also commits any files you’ve changed since then.
git status
To show all files that got changed. To show is the folder that we are working on is a git folder other with you get an error massage says that “fatal: not a git repository”.
git log
Show a history or a log of the last commands you executed in your machine. -n where n is a number of log you want to display from the last usage.
git remote
Display all remotes in that specific git folder.
git remote add origin <https://github.com/yourname/repo>
git push —all origin main
…or create a new repository on the command line
echo "# react-s" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/makkawysaleh/react-s.gitgit push -u origin main
…or push an existing repository from the command line
git remote add origin https://github.com/makkawysaleh/react-s.gitgit branch -M main
git push -u origin main
GitHub copy a repo and uploaded to another you own.
git clone <https://the-repo-url-you-want-to-clone.git>
cd [to-it]
git init -b main
git add .
git commit -a -m "A message to the commit."
git remote add origin <https://the-url-of-the-new-repo.git>
git push -u origin main