===============================================================
Create repo in github & add ssh keys to github
----------------------------------------------------
Note:
----
path of ssh keys generated:
in windows ==> /c/users/<your_user>/.ssh/
in linux ==> /home/<your_user>/.ssh/
How to Add SSH key / public key ( id_rsa.pub ) to GitHub ?
==> Github-homepage --> click on your profile(top right corner)--> Click on Setting ---> SSH and GPG keys ---> New SSH key or Add SSH key ---> Provide the name/ Title for key -->paste the content of id_rsa.pub file copied --> Add SSH key field
To start version controlling from a remote repository (GitHub):
--------------------------------------------------------------
generate ssh key & add it to github
Steps1:
-------
create a new repository in github
step2:
------
download this repository to my laptop for very first time
to get url : go to your repository page in github, code==> ssh ==> copy the link
command: git clone <url_of_repo_created>
git clone git@github.com:ravirekha/Remote_repo.git
git@github.com:ravirekha/Demo_Remote_Repo.git
step3:
------
after downloading,
add your code files to local repository
step4:
-----
upload files in local repo to remote repository using git push
git push
step5:
------
clone the repo in EC2 server & again add few files & push the changes to remote repository
step6:
------
Pull the changes in your laptop using git pull....
keep on doing this cycle
------------------------------------------------------------------------
Git clone:
==========
git clone command is used to bring the remote repo to local workspace for the first time.
Syntax git clone <url_of_repository>
cloning we can be done using two options:
1. clone using https: we need to give my github credentials while pushing & pulling
2. clone using ssh: is highly recommended , it will use ssh keys so doesent ask for password
Git push:
===========
git push is used to push the changes from Local repository to Remote repository
syntax: git push
Git pull:
============
git pull will bring the changes from remote repository & merges to local repository automatically.
Git fetch:
===========
git fetch will bring the changes from remote repository & stores it in seperate branch , we can review the changes if required we can merge.
mathematically: git pull = git fetch + git merge
** Diffrence between git pull & git fetch**
If you want to review the changes before merging, you can use commands like:
git log origin/main
If you want to merge the changes into your current branch
git merge origin/main
=================================================================
Merge conflict
==============
Merging conflict will occur when the same peice of code is changed on two different branches & when we try to merge these two branches merge conflict occurs
How do you fix merge conflicts?
===============================
1. I dont know what changes to keep , I will discuss with both developers about what content to keep, then we will decide what changes we need to keep & then i will proceed with merging
2. we can use tools like Visual studio code, which can resolve merge conflicts.
---------------------------------------------------------------------
.gitignore
-------------
.gitignore file is used to ignore the files from tracking in git
add file names in which needs to be ignored in to .gitignore file
$ cat .gitignore
*.log
testfile
-----------------------------------------------------------------------
Git Hooks:
==========
git hooks will impose some policies before & after commits.
Pre commit hooks
git will execute these files prior to commiting
Post commit hooks
git will execute these files after commiting is done
path of hook files: .git/hooks/
-------------------------------------------------------------------------