Git and GitHub Tutorial || Git Architecture || Git Crash Course || Professional Git | Code Decode

Pubblicato il: 03 giugno 2020
sul canale di: Code Decode
20,314
458

Git and GitHub Tutorial || Git Architecture || Git Crash Course || Professional Git (Things no one taught)
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
https://openinapp.co/udemycourse

Course Description Video :
https://yt.openinapp.co/dmjvd

This is a git tutorial for beginners/ github tutorial using git bash only. Hence it will enhance the knowledge of git commands as we will do all the operation used in git using git bash and git command manually.
There are many GUIs available but using commands will be the best way to learn git.

To learn git in professional way we need to learn git using git bash and git commands .
This git tutorial or git hub tutorial answers the most important interview questions as to what is git? what is github? how to use git bash? how to learn git ?
what is git rebase? what is git repository, git commit, git add , git branching , git merge vs git rebase ? , git merge, git push, git checkout which are most of the git basics.
git Merge vs Rebase is the very important interview question when version control systems comes into picture in git learning and git basics


**************************Commands Used**************

Git is a free and open source distributed version control system.
Generating a new SSH key and adding it to the ssh-agent using git bash

Step1 :
ssh-keygen -t rsa -b 4096 -C (gmail id)

Then u will press enter and at default location shown there: (/c/Users/XXX/.ssh/id_rsa)

start the ssh-agent in the background
$ eval $(ssh-agent -s)

Now add it to agent

ssh-add ~/.ssh/id_rsa

$ git init
With this command we will initialise local directory as git repository. Till now our code is in working area

$ git add . -- with dot
Adds the files in the local repository and stages them for commit. These files are prepared to be commited. So now files are moved from working area to staging area

$ git status
to see ur files. In staged, unstaged or untracked status. After commiting u will not see the file here.

$ git commit -m "First commit"
Commits your tracked changes on your local repository and prepares them to be pushed to a remote repository. So now files moves from stage to local repo.

git remote add origin git@github.com:Code-decode-learning/git-demo.git
add url for remote repository in which your local repo will be pushed .

git remote -v
Verify new remote url.

$ git push –u origin master
Pushes the changes in your local repository up to the remote repository you specified as the origin

Git and github tutorial for beginners that we cover here uses concept of forking created at github.
git commands will be same for forked one and for organisational level repositories.

For forked repos :

Go to your .config file in .git and check upstream and origin.

Upstream should be from where u can take pull. Means your main repo of organisation.

Origin must be your forked where you will push your code and raise a pull request so that on approval those changes can be merged to upstream branch or organisation.


git remote add upstream (url).

git remote add origin(url).


We have already seen:
Git init [repo name] : This command is used to start a new repository.
Git clone : used to obtain a repository from an existing URL into local repository.
Now:

Git add [file] - This command adds a file to the staging area.
Git add .(dot) - This command adds one or more to the staging area.

git diff: Show unstaged changes between your index and working directory.

git commit -m “[ Type in the commit message]”
Usage : git commit –am “my message”

git status : List which files are staged, unstaged, and untracked.

Git log : Display the entire commit history using the default format. For customization see additional options.


git push origin $branchname:$remote_branchname
like --- git push origin master

Git pull -) this command will pull changes from default remote repository which is origin n not upstream, if wanna pull from upstream then use command git pull upstream master.


git fetch: fetches the changes from remote repository but will not affect your local so will not give u any merge confict,
The interesting thing about the fetch command is that it doesn't actually affect anything in your local repo. No working changes will be lost, and you'll see no direct affect on your local branches. This is because Git keeps fetched content separate from your own repo's content until it is merged in.

git fetch (remote-repo)
$ git merge FETCH_HEAD

So obviously the big difference between fetch and pull is that pull actually performs a fetch in addition to a merge.

#git #github #gitandgithub


In questa pagina del sito puoi guardare il video online Git and GitHub Tutorial || Git Architecture || Git Crash Course || Professional Git | Code Decode della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Code Decode 03 giugno 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 20,314 volte e gli è piaciuto 458 spettatori. Buona visione!