COMPLETE GIT TUTORIALS

1 = WHAT IS GIT/GITHUB & WHY DO WE NEED IT 


What's Up everyone. Today I am going to discuss Git and Github . So today i am going to talk about what is Git?, Why is it around? and What is Github?. So Let’s get started.

Git: So Git is a version control system. Let’s assume I have made an AI desktop assistant. Now I was working on version 1 which has 3 files, f1, f2, and data.csv. After a few days I have changed the code and made version 3 which also has 3 files, but this time f1, f2 file doesn't exist, instead it has f3, f4 and data.csv. So now f1, f2 files are not around. If in the future we get into a situation where we need those files there will be no option, but if we use a version control system like Git then we can go back and see those files and work with it. 

 

Pros of Version Control System:

  1. Easy File Recovery: You can easily recover files from the version control system.
  2. Issue: If more than 1 person is working on a project and the project stops working after someone’s commit then you can easily check who’s commit it was and rollback.
  3. Rollback: You can easily rollback to a previously working state.

History Of Version Control Systems: 

Local Version Control System: So the first version control system made by programmers was a Local Version Control System, which used Database to keep track of files. But the major drawback was all the changes were saved in the computer. So if the computer gets corrupted then all of the data will be gone. 

Pros:

  • You can track files.
  • You can Rollback.

Cons:

  • If the local Computer/ Laptop gets corrupted then all of the data will be lost.
 

Centralised Version Control System: So after Local Version System the programmers made Centralised Version Control System. In the Centralised Version Control System the changes were saved in a server, so there is no chance of losing all the data and the changes due to data corruption. The programmer needs to pull the file from the server, make his changes and then push that modified file to the server. Now there is a chance that if the server gets damaged then the files can be lost forever.

Pros:

  • You can track files.
  • You can Rollback to a specific version of the file.
  • Changes were saved in a server instead of a local computer.

Cons:

  • If somehow the server gets damaged then the files and changes will be gone.

 

Distributed Version Control System: This is almost like the Centralised Version Control System. The only difference is when the programmer pulls the file he gets the complete changes of that project and each programmer has a complete backup of the server. So if the server gets damaged the programmers can fix it easily without losing any files.

 

How was Git Started: In 2002 the programmers who were working for development of Linux started using Bitkeeper VCS as their version control system. But in 2005 Bitkeeper removed their free of charge status from them and asked to pay the Linux Development team a huge amount of money. After this Linus Torvalds, the creator of Linux  started making his own version control system and then he made Git, a free Centralised Version Control System.  And everyone started using Git. 

 

Features of Git:

  • It stores the snapshot not the differences so the only file which is changed will be stored and disk space will be saved.
  • Almost every operation is local. You can work on your local machine and then push those changes to the centralised repository.
  • Git has integrity. Git generates SHA-1 Checksum for each and everychange, so only those who have access can modify files.
  • Git generally adds data. So as you change the versions it stores them.

 

Github: Github is a hosting website which hosts Git repositories. Git is free to use but Github charges for managing those files. There are also alternative websites which host git repositories like BitBucket, Gitlab etc. Among these Github is most popular. 

So that was pretty much it. Thank You for reading. 



2 = Installing Git + Initial Setup?


Installation:

  • Navigate to Git’s homepage and download the installer.
  • Open the Installer and follow the simple steps to install it.
  • Done.
  • Now Search for Git Bash on the search bar and open the application.
  • To check if git is installed correctly, type git and press enter in git bash. If you don’t get an error then it is installed correctly.
  • You can run git from powershell too. Just type git there to verify it.

 

Setup:

  • You can use the CD command to navigate through folders.
  •  Create a folder where you want to run git and open the folder
  • Now right-click while pressing shift and choose Open git bash here.
  • Let’s setup the username and email by running these codes: 
    • git config --global user.name “Username” then press enter.
    • Again type git config --global user.email “UserEmail@useremail.com” and press enter again.
  • Now type git config --list to show the configuration and verify that you have entered the correct name and email
  • You can also change the editor by entering the command git config --global core.editor vim to use vim as editor.






3 = THREE STAGE ARCHITECTURE


Let’s assume we are working on a project which has an index.html file, a folder named static and engine.js file. Now you have completed this and made it version 1 of this project. Now you want to add more features into it and if anything goes wrong, you could roll back to version 1 which runs perfectly. In this case, you will take a snapshot of the project. Which means you will save a state of this project where it is running without any errors. This process is called “Commit”. Now you have committed this project as C1 and continued to work. Now You have changed index.html and also the other files, but somehow engine.js file is not working anymore. So, in this case, you will just put index.html file on the second snapshot and pull the other working files from the first snapshot. This is where Three-stage architecture comes.  

We have 3 areas in the Three-stage Architecture:

Working Directory: 

The working directory is the folder in your local computer where the project files and folders are stored.

Staging Area: 

The staging area has those files who are supposed to go to the next commit. Only those files which are needed to go to the next commit stay in the staging area. Like, suppose you are working on that previous project and you have upgraded the index.html file but somehow you broke the engine.js file, so now you will just add the index.html file to stage area so it can be added to the next commit and the engine.js will be used from a previous version. And as you have not staged the broken engine.js file, the broken fill will not be committed. 

Git Repository: 

Git repo is a hidden file named .git. It stores all the commits and compresses them. So when you need a specific commit it can present that to you.


4.Tracking Our first Git Project | Git Tutorials 



11) to check the status of git repository $ git status 12) to make your directory a git repository $ git init 13) to make all of the files and folders in git repository ready for next commit (Or we can say putting them in staging area) $ git add --a 14)To commit (Or we can say taking snapshot of your staged files) $ git commit -m "<message>" 15)To see recent commits on git repository $ git log 16)To stage particular files in your git for next commit $ git add <file name>


Let’s say we have 3 files in a folder for which we want to create a git repository. So follow these steps to track these files using git.

  • Open the folder, Right-Click anywhere while shifting and choose “Git Bash Here”.
  • After Git bash is opened type “git status”.
  • It will give you a message that “fatal: not a git repository (or any of the parent directories): .git”.
  • It is a message that says these files are not considered as a git repository.
  • Now we will type “git init” to initialize this folder as a repository. 
  • Now if we type “git status” then we will get the files which are present in the folder. Also, it says there that the files are not tracked. 
  • Now to track all the files inside this got repository we will type “git add --a”, which will add all these files to the staging area.
  • Now we have to commit using this command “git commit -m “Initial Commit””.
  • Now if we do git status again it will say There’s nothing to commit, working tree clean. Which means we have successfully tracked our files.
  • Now to see the commits we have made, we will use “git log” command.
  • Now if we modify a single file and want to stage that only file we will use “git add file.ext”(Where file.ext is the filename and extension).
  • Now we will commit with a message by typing “git commit -m “Your commit message””
  • Done Now You have successfully tracked your files.

 



 5 .Cloning a Remote Git Repository from GitHub:

 (A) git commit -m = "changed FIRST.TXT  and added better design"  FOR A                                                             PATICULAR  FILE.
(B) rm -rf .git = TO DELETE ALL GIT REPOSITORY

(C) git clone [shift+insert] to paste copy address

(D) pwd = PRESENT WORKING DIRECTORY

(E) ls = LIST CONTENT

(F) cd = CHANGE DIRECTORY


Hey everyone welcome, We are going to learn about Cloning a Git Repository from Github. So let’s get started.  

Steps:

  • Open Browser and go to the GitHub page of that git repository.
  • Let’s say for an example we are cloning Tensorflow’s repo.
  • Let’s navigate to the official Github repo of Tensorflow.
  • Now click on code or download and copy the URL.
  • Open git bash and type “git clone (copied URL)”
  • Example: “git clone https://github.com/tensorflow/tensorflow.git
  • Wait for the git clone to complete, this will only take a little bit of time for the first time.
  • Now you can change the files locally, track them also commit them locally.


6.Git: File Status Lifecycle








whenever you run add command the file/files get(s) staged with its/their present status. now if you commit, only those versions will be saved. if you make modifications, now you must run add again if you wish to commit that modified version.


Hey everyone welcome, Today we are going to learn about File status life cycle. So let’s get started. When you start to track files on an empty repository every file stays in the untracked stage. Which means we have not staged these files. So after adding the files by typing “git add --a”, every file moves into the unmodified section. Now if we change a few files they will be moved to modified and staged. Now what happened here is, we have added every file to the tracker and now as we modify files will be moved to the modified phase. Now if we run the add command then the files which were in the modified stage will be staged.

  • Let’s open a new folder and initialize as a git repo by opening Git bash and typing “git init”
  • Now lets add the files by using “git add --a”.
  • Now every file has been staged.
  • Now if we change 1 file and do “git status” then you will see that the file we changed is present both on staging area and untracked area. Because you have staged the file and those are meant to go to the commit until the user stages other changes. So only those will go to the next commit which are staged. The untracked files will be ignored unless the user adds them to stage.



7.gitignore: Ignoring Files in Git


20)To ignore some files to track in git repository i) -> Create text file named ".gitignore" using command (if not exist): touch .gitignore ii)-> Add the name of the file to be ignore in .gitignore file 21)To ignore every file based on extension ii) -> Write *.<extension> in the .gitignore file example : if we want to ignore all files having .log extension open .gitignore file and add " *.log " in that file. 22)To ignore folder inside git repository ii) -> Write <foldername>/ in the .gitignore file example : if we want to ignore all folder named "dir" inside git repository open .gitignore file and add " dir/ " in that file. 23)To ignore outer folder inside git repository ii) -> Write /<foldername>/ in the .gitignore file example : if we want to ignore outer folder named "dir" inside git repository open .gitignore file and add " /dir/ " in that fil

24 empty folder by default nhi dikhta


What is gitignore?

.gitignore is a file which tells git which files (or patterns) it should ignore. It's usually used to avoid committing unnecessary files from your working directory that aren't useful such as compilation products, temporary files etc.

Now Let’s see how to add .gitignore to your repo and ignore files

  • Let’s start by creating an unnecessary file. 
  • Open git bash on that folder and type “touch file.log”
  • Now you will see file.log will be created.
  • Now we will gitignore this file.
  • Again open git bash and type touch .gitignore.
  • Now if you do “git status” it will return you 2 untracked files, .gitignore and file.log.
  • Now let’s open .gitignore file using notepad, type there file.log and save and close it.
  • Now if we do “git status”, it will return only 1 file, which is .gitignore. Because the other one will be ignored. 
  • Now type “git add --a” to add gitignore to the staging area.
  • Now let’s commit by typing “git commit -m “added .gitignore””.
  • Done! We have successfully created .gitignore for our repo. 

Ignoring Specific Extension files:

  • Create .gitignore the same as the last one.
  • Now open it using notepad and type there “*.extension” to ignore. (example for ignoring .log files : “*.log”)
  • Now save and exit the notepad and commit the gitignore to your repo.

Ignoring Folders:

  • Now we will ignore a whole directory.
  • Create and open .gitignore and type there the directory name followed by “\”. (example: dir/ )
  • If you create a blank folder, git will automatically ignore it.



So that’s it for the .gitignore. I hope this has cleared your doubts. Thank you for watching.



8.Git Diff: Showing Changes Between Commits/Staging Area & Working Directory


24)To compare same named files present in both staging area and working area $ git diff 25)To add modified file in staging area again $ git add . 26)to compare same named files present in staging area and last commit $ git diff --staged


git diff --staged ====> Compare previous commit to recent staging area . git diff ===> compare staging area with working directory (modified files ).

What is Git Diff?

Diff command is used in git to track the difference between the changes made on a file. Since Git is a version control system, tracking changes is a very vital part to it. Diff command takes two inputs and shows the differences between them. These inputs can be branches, working trees, commits and more. Now Let’s learn about Git Diff in these simple steps.

  • Let’s start by staging one file. 
  • Open git bash on that folder and add that file into the staging area by typing “git add --a‘.
  • Now if you do “git status” it will show that the file has been staged.
  • Now if you modify the file and do “git status”, it will show that the file has been modified and not staged for commit and also it will show that the file is ready to be committed. Why does it happen? It happens only because we have staged the file earlier so it has moved to the staging area and is ready to be committed, and when we have modified it, it also shows up on the modified area. We have seen this happen earlier too. 
  • Now let’s compare the working directory with the staging area so we can see those changes.
  • Type “git diff” and see the output.
  • The output should look like this.

  • The red line shows that the lines are modified or deleted on the staging area and the green shows things added on the working directory.
  • Now if we do “git add --a” and do git diff it will show nothing because we have staged every change.

 

Git Diff in previous commits:

  • If we use “git diff --staged” it will compare every commit with your working directory.

So that’s it for the Git Diff.. I hope this has cleared your doubts. Thank you for watching.




9.Git: Skipping The Staging Area


27)To direct commit tracked files (without staging) $ git commit -a -m "commit message"

Hey everyone welcome, Today we are going to learn how to skip the staging area. So let’s get started.

  • Let’s modify a file in our directory.
  • Now open git bash in that directory. 
  • If we do “git status” it will show us that the file has been modified but not has been staged.
  • Let’s create a new file on that directory and do “git status”
  • It will show us that the tracked file (the file we modified earlier) has been modified but not added to the staging area and the new file is untracked.
  • Now let’s skip the staging and directly commit.
  • NOTE: Only tracked files can skip the staging area, to add your file to tracker type “git add --a” or “git add filename.extension”.
  • Now let's skip the staging by typing “git commit -a -m “Commit Message””.
  • Now if we do “git status” it will show that the working directory is clean. Which means we have successfully skipped the staging area and committed the changes.

 

So that’s it for skipping the Staging Area. I hope this has cleared your doubts. Thank you for watching.


when you will grow more and actually use git to build some kind of software then you may have to change a lot of the files and then you think I only want to commit a single file and still want to do work in another file which is in the staged area. At that time doing "git add <file name>" and "git commit -m " instead of writing 2 commands separately while having a command that does all the work of 2 commands in a single line, would be preferable.


10.Moving and Renaming Files In Git |


28)To Rename file $ git mv <present-name> <new-name> 29)To Delete file $ git rm <file-name> 30)To make the file untracked from tracked $ git rm --cached <filename>

we un-track multiple files of sametype
use *.<extension> for that

Hey everyone welcome, Today we are going to learn how to move and rename files in git. We can also do it manually but then, we need to stage those changes using git bash. That is why we are going to do it inside git. Git will automatically stage it after moving/deleting/renaming that file. So let’s get started.

Deleting Files:

To delete files using git we need use this command: “”git rm filename.extension”. It will delete the file and if you do “git status” now it will say that the file has been deleted and staged. Now we can commit it by using the “git commit -m “commit message”” command.

Renaming Files:

To rename file we need to use this command : “git mv filename.extension renamefile.extension”. It will rename the file from filename.extension to renamefile.extension. And it will also get automatically staged by git. All we need to do is commit.

Untracking Tracked Files:

To untrack a specific file we need to use “git rm --cached file.extension” command. It will remove that file from the tracker and it will become an untracked file.

 

So that’s it. I hope this has cleared your doubts. Thank you for watching.


once we add *.log in .gitignore file, After this the log files added to the working tree will not be tracked anymore.
But it might be the case that few *.log files were already committed and after that you decide to ignore those. For example, you have created a file "first.log", added to staging area, committed it. Now you decide you do not want to track any log files -> you will add *.log in gitignore file, commit gitignore file. Now you create "second.log" it will not be in untracked files. But still if you change "first.log", this file will come under modified files. in that case, we have to use "git rm --cached first.log"
After this, any change made to first.log will never be tracked.
Show less


11.Git Log: Viewing & Changing Commits In Git


Hey everyone welcome, Today we are going to learn how to view and change commits on a git repository. So let’s get started. 

Commits History:

To see the commits made on the git repo, we need to type “git log”. After typing this you can see the commits that have been made on the repo. To exit we need to type “q” on our keyboard and press enter.

Diff in Commits:

To see the Diff in a commit we need to use “git log -p”. It will show what has been changed on a commit. To see specific no commits with changes we need to use “git log -p -2”(for seeing the last 2 changes).

Brief Summary:

Also we can get a brief summary of commits by typing “git log --stat”.

If you want to see the commits on one line then type “git log --pretty=oneline ”.

Customized Commit Output:

If you just want to see the commits and The author then use “git log --pretty=short”. And if you want a little bit more info like who is the committer, commit message, then use “git log --pretty=full”.

If you want to filter commits by time, then use this command, “git log --since=2.weeks”. To see the last 2 months of data type “git log --since=2.months”.

We can format the output by using the formatting  codes provided in Git’s website. For an example we can use this format to print just the author name and the hash : “git log --pretty=format:“%h --an” ”. 

Changing A Commit Message:

Now to change a commit. So, to change the most recent commit we need to type “git commit --amend” and press enter. Then an editor will open where you can change the commit message. All you need to do is change the message and then you need to close it by pressing i then esc key then type “:wq” to exit the editor. Now you have successfully edited the commit.

12.Unstaging & Unmodifying Files In Git 

Let’s say we have few files in our git repository and we have staged them. Now for some reason we want to unstage a file. Now how to do that? It is super easy. Let’s see.

  • To unstage a file use “git restore --staged file.ext”. It will unstage the file and you can verify it by using “git status”. 
  • Now let’s say we have modified the unstaged file and made some changes which were not necessary. Now the program is not working. So we have to restore that file to its previous state where it was working. To do it use “git checkout -- file.ext”. Now git will restore that file to its last commit state.
  • To restore your entire working directory to the previous commit use “git checkout -f”. It will restore your entire directory to the last commit. 

 39)To do modifications in previous commit message

$ git commit --amend 40)To make file unstaged from staged $ git restore --staged <filename> 41)To make File restore/unmodify to previous commit $ git checkout -- <filename> 42)To make all File restore/unmodify to previous commit $ git checkout -f

13.GITHUB:WORKING WITH REMOTE REPOSITORY

Let’s start by going to Github’s official website and creating an account. After you have created your account you need to go to the home page and click on the create a new repository option. Now give your repository a name and description. Now click on create repository. Now it will show you a page for quick setup. Now let’s make our local repository a remote repository.

 

Steps:

  • Go to your local directory and open git bash there.
  • Now we have 2 options, 1: If we have not created a git repository in our system then follow the first method, 2: We have a git repo in our local system we just want to push it to the remote system then follow the method 2.
  • We are following Method 2 Here.
  • So let’s copy the code on git’s website which looks like this “git remote add origin git@github.com:yourusername/repositoryname.git” and paste it to the git bash and press enter.
  • Now we will paste the second command which pushes the files onto the remote server which is “git push -u origin master”.
  • It will give you an error that access is denied. Now let’s tackle this.
  • To fix it, go to your account settings on github, then SSH and GPG keys. Then click on the new SSH key, add a title. Now for the key, open git bash and follow the simple steps.
  • On git bash type the following edit your email and press enter: “ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ”
  • Now just simply press enter 3 times.
  • Now run this command “eval $(ssh-agent -s)”.
  • Now run this “ssh-add ~/.ssh/id_rsa”.
  • Now on git bash type this to reveal your key “tail ~/.ssh/id_rsa.pub”.
  • Now it will show you the ssh key. Just simply copy it.
  • And now let’s head back to the github SSH key page and paste the key to the key field, press add ssh key. And done!
  • Now if you run “git push -u origin master” it will run and push your files to github.
  • Now you can make changes on your local git repo and push the changes to the remote repo swiftly

14.Setting Alias In Git

What is Alias?:

Alias is a term which is associated with shortcuts in Git. It shortens the long commands to increase efficiency. So let’s see how to set up an alias.

Setting Up Alias:

  • Open git bash and now type this command to set up alias for “git status”.
  • Type “git config --global alias.st status” and press enter. Now what it means is if we type “git st” it will give us the output of “git status”.
  • Let’s do another one. 
  • Now type “git config --global alias.unstage ‘restore --staged --’ ”.
  • Now if you type “git unstage” it will work as “git restore --staged --”.
  • We can set up as many aliases we want. Like we can create an alias for seeing the last commit done by the user.
  • To do that type “git config --global alias.last ‘log -p -1’ ”.
  • Now if we type “git last” it will show us the last commit done by the user.

 

 

15.Git: Creating & Switching Branches In Git

What is Branch?

Branch is a way to add new features or modification to the software and not affecting the main part of the project. We can also say that branches create another line of development in the project.

Now Let’s see how to create and switch to a branch:

  • Open Git Bash on your local repository.
  • Let’s create a branch by typing “git checkout -b branchname”.
  • Now if you modify the files in the repo and do “git status” it will show you “on Branch branchname” which means you are changing files on the branch you have created.
  • Let’s stage these files by using “git add . and commit these changes by typing “git commit -m “commit message” ”.
  • Now if you do “git checkout master” then you will see that the files on your repo will revert to the master branch where we haven’t made any changes.
  • Now if we do “git checkout branchname we will switch from master branch to our newly created branch where we have modified files.

 

So this is how you create and switch to different branches. 


* Branching ( To avoid changes in master branch , people create branches and work in that branch) * 45) To create new branch $ git checkout -b <new-branch-name> 46) To switch into different branch $ git checkout <branch-name> 47) TO check all the branches in git $ git branch

Show lesgit restore filename.txt //Restore a file to its previous content of commit:
git checkout -b develop//Create a branch with name 'develop' and switch to that branch, -b = branch i.e means make new branc
git branch //see all branchesgit checkout branchName //shift to a already made branch branches are not pushed by default.


16.Branching & Merging a Production Grade Project

 Hey everyone welcome, Today we are going to learn how to merge branches in Git. So let’s get started. 

Note: This is a recap video of everything we have done so far in this series. Also I have explained merging branches in this video. If you want to recap everything and then want to learn git merge, then watch the complete video. And if you just came to learn merging see down below.

Let’s see how to merge branches:

  • Open Git Bash on your local repository.
  • Let’s create a branch by typing “git checkout -b branchname”.
  • Now if you modify the files in the repo and do “git status” it will show you “on Branch branchname” which means you are changing files on the branch you have created.
  • Let’s stage these files by using “git add . and commit these changes by typing “git commit -m “commit message” ”.
  • Now if you do “git checkout master” then you will see that the files on your repo will revert to the master branch where we haven’t made any changes.
  • Now if we do “git merge branchname” it will merge those branches.
  • Now we just need to stage and commit those changes by typing “git add .” & “git commit -m “commit message” ”.

 

So this is how you merge 2 different branches. I hope this has cleared your doubts. Thank you for watching.


17.Resolving Merge Conflicts (With Example) 





When Merge Conflicts happen?

When you merge branches that have competing commits, and Git cannot decide which changes to incorporate in the final merge, that's when merge conflicts happen.

Resolving Conflicts:

There are many ways to resolve conflicts on Git Merge. But we are going to use the easiest one. By using VSCode. Just Install VS Code in your system and open those files who have conflicts, and you will see 2 options: Current Change and Incoming change. Just like this.

Just choose Accept Incoming change. Save the file and commit the files by typing “git add .”, and “git commit -m “message” ”. Now you have successfully merged 2 branches.

Branch Management:

We can create many branches in our repository and work in them. We also need to manage them. So let’s see few commands for managing branches in Git:

  • To see all the branches you have created you will need to use this command : “git branch and the current branch will have “*” in front of the branch.
  • To see Branches and that branch’s last commit along with it’s message type “git branch -v” and press enter.
  • If you want to see which branches were merged then use “git branch --merged” and those that were not merged use “git branch --unmerged”.
  • To delete a branch we need to use “git branch -d branchname”. Note that this command will fail if the branch we are deleting has not merged to the main branch. To tackle this error we will use “git branch -D branchname”, it will delete the branch even if it's not even merged yet.
  • 49)To check all branches with their last commit hash code and message $ git branch -v 50)To check which branch are merged $ git branch --merged 51)To check which branch are not merged $ git branch --no-merged 52)To delete branch $ git branch -d <branch-name> 53)TO delete unmerged branch $ git branch -D <branch-name>
 18.Git Branching Workflow in Production


 




 Hey everyone welcome, Today we are going to learn about Branching Workflows in Git. So let’s get started. 

When people usually use git they create branches and primarily they create 2 types of branches.

Long Running Branches:

A long-running branch is a branch under active development that is not merged to the main branch for a long time. The main branch might be, for example, master or develop.

Topic Branches:

Topic branch is a short lived branch which was created for a single particular feature or related work. Topic branches can be deleted after the particular feature is added to the project.

Example:

Let’s assume you were working on a project where you have committed C1 on the master branch and then an issue has arised and to solve that issue you have created a new branch called issue and you have committed C2 and you came back to master to complete the work and committed C3 on master and went to the issue branch and committed C4, C5 and C6. When you were on C4 you came across another new issue and to fix that you have again created another new branch called Issue1 V2 and committed C7, C8 and C11 where you have solved that issue. After that you came to the Master branch and committed to C9, C10 and you got an idea. To implement the idea you created another branch named IDEA and committed C12 and C13. Now you want to Merge IDEA on to Master. Also you want to commit Issue1 V2 too. Now you have merged C11 of Issue1 V2 branch and C13 of IDEA branch and created a commit named C14 which is your master branch.

So this is it. I hope this has cleared your doubts. Thank you for watching.

Summary: Branching workflow: 1. Long running branches: master, develop, proposed update 2. Topic Branches: replace jquery with react Detail: Long running branches: which will exist till end of project Topic branches: new features will be added and branches will be temporarily used.


19.Pushing Git Branches To Remote Repositories

Hey everyone welcome, Today we are going to learn How can you push your branches to remote servers like Github. So let’s get started. 

So let’s open git bash and run “git status” so see if you have any files to track and “git log” to see what you did on your last commits. Also check the branches you have in your repo by typing “git branch ”. Now let’s go to github.com and login using our username and password. After that click on New repository, and Give a name and description to your repository and press Create repository. Now look for the “Push an existing repository from the command line” tab and copy the first command which looks like this “git remote add origin git@github.com:username/reponame.git”. Now come to the git bash and paste this command. Now if you do “git remote -v” it will show you that Origin has been added. Now Let’s push our code by typing “git push -u origin main”. Make sure that you have staged and committed your files. When you press enter after the command it will open the github login page, and you just need to login using your same github account and press login.

Now we will push our other branches to github. First let’s switch the branch by typing “git checkout branchname”. And if we now type “git push origin branchname” and press enter, it will push that branch to github and we can check that on github.

We can also merge our branches to the main branch and push the changes. We need to switch to the main branch first by typing “git checkout main” Now we will merge the branch by typing “git merge branchname” and merge it. Now we will delete the unnecessary branch by typing “git branch -d branchname”. Now if we do “git status” it will show us only the main branch. And now we will push the changes by typing “git push -u origin main”. Now also remove the branch from remote repository too by typing “git push -d origin branchname”. And now if you check on github you will see that the branch has been deleted.

 

So this is it. I hope this has cleared your doubts. Thank you for watching.






Comments

Popular posts from this blog

HOW IMPORT WORKS IN PYTHON?

Exercise 5: Health Management System

*args and **kwargs In Python