Giter Site home page Giter Site logo

git-tutorial's Introduction

  1. git init -> Powers your folder to be managed by git, and initialises a new empty repository. It also creates a .git folder that has all the relevant logic to manage versions of your project.

  2. Working Area -> There can be a bunch of files that are not currently handled by git. It means that changes done or to be done in those files are not managed by git yet. A file which is in working area is considered to be not in the staging area. When we do git status and we see abunch if untracked files then these are actually called to be in the working area.

  3. Staging area -> What all files are going to be part of the next version that we will create. This staging area is the place where git knows what changes will be done from the last version to the next version.

  4. Repository Area -> This area actually contains the details of all you previous registered version. And the files in this area, git already manages them and knows their version history.

  5. git add <file> -> moves file from working area to staging area

  6. git rm --cached <file> -> moves file back from staging area to working area

  7. commit -> Commit is a particular version of the project. It captures a snapshot of the project's staged changes and creates a version out of it.

  8. git commit -> registers staging changes to a commit.

  9. git log -> list downs all the commits of the repository. If you want to exit out of git log prompt press q.

  10. git restore <file> -> it removes all files changes from the staging area to be committed. This can be useful, if we did some dirty piece of code and now no more want it. Instead of deleting every change line by line, we can restore it or you can say restore last clean version of the file.

  11. git restore --staged <file> -> it removes file from changes from staging area to the working area. this only works if changes are in your staging area

  12. Diff between git rm and git restore ans: if you want to move the whole file back to the untracked state, then we do git rm, otherwise if we just want the changes to be moved in working area or staging area then we git restore.

  13. git diff commit1 commit2 -> gives the difference of all file changes between two commits

14 git commit -m "<your commit message>" -> If we want to avoid opening a text editor like vim/nano to add commit message we can use this following command

  1. git remote -> list down all the remote connection names

  2. Remote connection -> It helps you to link two git repositories for uploading and downloading changes from each otherwise

  3. git remote add <name of remote> <link of the remote> : this command helps us to add a new link to the remote repo and give a name to it

  4. git remote rm <name of remote> : this command deletes a remote connection

  5. git remote rename <olanme> <newname> : this command remanes the remote connection

Note: The name of the remote connection is always used to establish communication between the repos

  1. git add <file1> <file2> <file3>: this command will add multiple file changes together in the staging area

  2. git add .: this command will add all files from working repo to staging area.

  3. git pull <remote name> <branch name> : downloads latest changes from the branch of the mentioned remote in your local repo.

Recommended practice to do

- make changes
- git add <file>
- git commit 
- git pull
- git push 
  1. Merge conflicts are a very common scnario

merge conflicts can occur if multiple people try to make changes to the same file, and then collaborate

git-tutorial's People

Contributors

singhsanket143 avatar

Stargazers

Kishlaya Kesarwani avatar Sarthak Bhandari  avatar  avatar Fkill D Azad avatar shashank avatar sourav sambit behera avatar Sanket Rakshe avatar  avatar Akash Goswami avatar Arun Kumar Malik avatar Mohini Mahato avatar Ashish Sharma avatar Shuvam Rauniyar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.