DEV Community

Cover image for How to work with git
Nita Nagdewate
Nita Nagdewate

Posted on

How to work with git

Step-by-step process

Git is a version control system used to track changes in software development.

How to get started with git?

  • Create a directory on your local machine, e.g., git-repos-test
  • Move to directory git-repos-test

  • cd git-repos-test

  • Create a repository on GitHub, e.g., test-git

  • Get the repository on your local machine using

  • git clone git@github.com:nitanagdeote/test-git.git

  • Move to the repository using
    -cd test-git

  • Create a React project or any other inside test-git, e.g., test-git-react-vite-project

  • Make changes in your project directory.

  • Check the status
    git status
    The result will show if changes are made or not.
    Add the changes using,
    git add .
    Then, commit the changes using,
    git commit -m 'commit name'
    The changes can be pushed to the git repository using
    git push
    Create a branch using
    git branch 'branch name'
    Switch to branch using
    git checkout 'branch name'
    To pull changes from the remote git repository
    git pull
    To see how many lines of code has changed
    git diff
    These are the basic commands to get started with git.
    To check if it's a git repo, use
    ls -a


Definitions
Remote: means the repository hosted on the server
Local: directory on the local machine
Origin: is also the remote repository
git: command line tool


What will you need to get started?
Terminal window to use the git commands
GitHub


Resources
Git - Wikipedia
Git () is a distributed version control system that tracks changes in any set of computer files, usually used for…en.wikipedia.org
GitHub: Let's build from here
GitHub is where over 100 million developers shape the future of software, together. Contribute to the open source…github.com

Top comments (0)