Git is a version control system that is used for tracking changes in computer files or managing work on those files among numerous people. It is mainly used for source code management in software development. Also, it can be used to keep track of changes in any set of files [1]. Basically, uploading source codes to store on clouds so that other people or developers can see the codes. There are many web-based Git and version control repositories available out there, including GitHub, GitLab, Bitbucket and so on.
To see common Git commands, simply type git in command prompt
Command clone is used to copy or clone a repository into a new directory.
Command branch is used to list, create, or delete branches in a directory.
To commit or upload to source codes to Git, first I will need to type git init to create an empty Git repository or reinitialize an existing one. Then I use this command git add . to add updated file contents to be uploaded to Git.
To add a short message to Git when making changes to the existing codes, type
git commit -m "message"
Then, I need to specify an URL to have the source codes uploaded. Type this command
git remote add origin Git’s URL
For the URL, it can be from GitHub, GitLab or Bitbucket. They all work in the same way.
In order to upload the source codes to Git, I type
git push -u -f origin master
All codes are now uploaded to git repository successfully.
-f command will force to push all codes to the repository. -f is useful when I download my source codes from the current repository to work on another computer and I will need to upload both existing codes and new codes from that computer to the Git.
To see the status of current git, I use this command git status.
Daily usage of Git
After making changes or updating the current sources codes, I can reuse the following commands to push the codes.
git add .git statusgit commit -m "added something"git push
References
[1] “Git”, En.wikipedia.org, 2017. [Online]. Available: https://en.wikipedia.org/wiki/Git. [Accessed: 07- Sep- 2017].