GitHub — make it easier

Stela Capsa
3 min readJun 15, 2021

Git is the most popular version control system in the world that records the changes in our code over time. With Version Control System we can truck our code history and also work together. There are two categories of VCS, Centralized and Distributed.

GitHub new repository

  1. Select New repository button from the drop down
  2. Give it a name
  3. Press create repository button

4. Create a project in any frame or language, I choose react as an example..

npx create-react-app [name of project]
cd [project name]

5. cd [project name], cd also known as chdir (change directory)

code .

6. code . will open the source-code editor

7. Will create the first commit with next commands, also to be able to commit we need to modify our code, than run the modifications with next command

git init

git init creates a git repository from your current directory.

git commit -m "any message"

git commit -m “…” saves the file with a description message

git push https://github.com/scapsa0116/newrepository.git

git push command updates the remote repository with local commits

Git branches

Git repositories can have one or more branches, the main branch is called master as default. Below is the presentation of branches and commits in time.

git status

git status command will show the current branch you working on.

git branch [name]

git branch [name] command will create a new branch,

git branch --list

In order to see al the list of branches created run git branch — list

git checkout [name of branch]

In order to switch to a new or other branch run git checkout [name of branch]

git branch

git branch shows all branches and highlights the current branch you working on.

git checkout -b [name of branch]

git checkout -b [name] command, creates a branch and immediately checkout as working branch, this command merges two commands mentioned before git branch [name] and git checkout [name of branch].

git push --set-upstream origin [name of branch]

git push — set-upstream origin [name of branch] command will push any modifications made on the current branch. Don’t forget, before that, you have initialize with git init . and after git commit -m “any message” and then we have to push it to origin with git push — set-upstream origin [name of branch].

git merge [name of the branch we want to merge in the master branch]

In order to merge a branch in to other branch, you have to be initial in the branch you want to merge the code in. As an example if you want to merge a branch in to the master branch, initial you have to be on the master branch.

git log --oneline

git log — oneline command will show all commits history with description.

GitHub is very powerful tool used by developers. Multiple people can work on the same project, build branches and then merge the changes to the main branch. Create, practice and be constant on developing.

Happy coding!

--

--