How Git Works — 7 Basic Steps for Beginners

  1. Create a repository (project).
  2. Clone (copy) your repository to your local machine
  3. Add a file to your local repository and commit (save) the changes.
  4. Push the changes to your main branch.
  5. Create a branch (version), make commit, push changes to the new branch.
  6. Open a pull request (propose changes to master).
  7. Merge your branch to master branch.

Prerequisites

Step 1: Create new Repository

Initialize Git

git config --global user.name "Your Name"
git config --global user.email "youremail@mail.com"

Step 2: Clone your repository

git clone ssh_url .

Step 3: Add new File and Commit

touch filename.txt
git add filename.txt
git commit -m "Initial Commit"

Step 4: Push changes to branch

git push -u origin branch_name

Step 5: Create new branch

git checkout -b new_branch_name
git push origin new_branch_name

Step 6: Create Pull Request

Step 7: Merge Branch

Delete a Branch

git branch -d branch_name
git push origin :branch_name

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store