Git Session

  • “git add .” : is a command used to add a file that is in the working directory to the staging area.
  • “git commit”: is a command used to add all files that are staged to the local repository.
  • “git push”: is a command used to add all committed files in the local repository to the remote repository. So in the remote repository, all files and changes will be visible to anyone with access to the remote repository.
  • “git fetch”: is a command used to get files from the remote repository to the local repository but not into the working directory.
  • “git merges”: is a command used to get the files from the local repository into the working directory.
  • “git pull”: is a command used to get files from the remote repository directly into the working directory. It is equivalent to a git fetch and a git merge.

User Case:

  1. When You first start the project:
  • Confirm git repo is there on the server or not.
  • Now you have to install git on your system.

Note: The GIt repo you have received is mapped to the master/Main branch

  1. Method to Connect Local Git to Server Github:
  • git remote add origin <url>
  • git push origin master
  • git push –set-upstream origin master
  1. Steps to Create a new Branch:
  • git checkout -b <new-branch(Name)>
  1. Next Run this command to get all the repo details from git.
  • git fetch

git fetch is a command used to get files from the remote repository to the local repository but not into the working directory.

  1. Method to commit your code on GitHub
  • git add.
  • git commit -m “<message>”
  • git push
  1. If you are going to work on an already ongoing project then take a clone
  • Git clone “reponame or SSH Url”
  1. If multiple developers are working on the same project with multiple branches, then how do we get other developers’ code from another branch?
  • Git pull origin <branch_name>

Sequence For Git Command :

  • Git status (to see which files changed)
  • Git add. (changes add to server)
  • Git commit -m (“[Module Name] – message”)
  • Git pull origin <branch_name> (to download file code from server)
  • Git push origin <branch_name> (to push all commits to server)

Leave a Reply