In this tutorial we will be using some basic commands of Git. We will be working with Github as the place where our repository can be accessed
For this tutorial we have the support of a Github App to do some actions over the repository. We will need you to grant access to the repository you created (git_practice)
Now that everything is setup we can start. In this case you are going to clone the repository. For this you need to open a terminal or CMD that can execute git commands. To check this you can try to execute git -v
git clone <URL from your repository>
. As an example, the command should similar to this git clone
https://github.com/dalthviz/git_practice.git
cd
) to get to the repository root directory. Doing cd git_practice
should be enough,Now that we have a local copy of the repository you can make changes to it. In this case the repository just has a README.md file. The idea is to modify this file and create a commit. The commit is basically a way to define a point for a set of changes made to files in the repository
git status
git add README.md
git commit -m"My first commit!"
Now you can push your changes to the remote repository that you have in Github. For that just do git push
The reason to use something like git and Github is to be able to work with others in an organized way. As you did, also others usually will make changes to the files of the repository and then there is a need for you to update the version of the files you are working on.
Pulling...
git status
git add README.md
git commit -m"My second commit!"
! [rejected] master -> master (fetch first)
Worry not what you need to do now is to do a pull with the following command
git pull
With this, now you have updated your local files with the info in the remote repository, but now comes the tricky part. Go to the following section to check what you need to do to solve a merge conflict
Although git lets you work in an organized way, sometimes you need to ensure the coherence of the files you are working on. Since not just you are working on the files sometimes the changes can enter in conflict. We handle this conflict by doing a merge
Merging...
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
<<<<< HEAD
, =====
, and >>>>>>> numbers
then:git status
git add README.md
git commit -m"My first merge commit!"
We manage to do some basic workflow using git and Github. Now a plus for you. In your Github repository exist a sections call issues. This section enables you to create trackable messages that you can use as tickets for bugs, features or discussions.
Issues...