Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Friday, 30 April 2021

Getting Started with Git - part one

Git is a version control system that allows you to track changes to your code and collaborate with others on software development projects. Here are the basic steps to get started with Git:

  1. Install Git on your computer. You can download the latest version of Git from the official website (https://git-scm.com/downloads).
  2. Open a command line or terminal window and navigate to the folder where you want to create your Git repository.
  3. Use the git init command to initialize a new repository in the current folder. This command creates a new subfolder called ".git" that contains the necessary files for the repository.
  4. Use the git add command to stage the files that you want to include in the next commit. For example, git add file1.txt will stage the file "file1.txt" for the next commit.
  5. Use the git commit command to save the staged changes to the repository. The m option allows you to add a message describing the changes. For example, git commit -m "Initial commit" will create the first commit with the message "Initial commit".
  6. Use the git status command to check the current status of the repository. This command will show which files have been modified, which files have been staged for the next commit, and which branch you are currently working on.
  7. Use the git log command to see a list of all commits in the repository, along with their corresponding messages.
  8. Use the git branch command to manage branches in your repository. You can use git branch to list existing branches, git branch newbranch to create a new branch, and git checkout branch to switch to a different branch.
  9. Finally, the git push origin <branch_name> (ex git push origin main) command to push the changes to remote repository.
These are the basic steps to get started with Git. As you become more familiar with Git, you can start using more advanced features such as branching, merging, and working with remote repositories.

It's important to note that Git is distributed version control system so you can work on a local repository and then push/pull changes to a remote repository. Most developers use Github, Gitlab, and Bitbucket as remote repositories.

Do comment if you're facing any issue on git.