Git allows us to keep track of the changes in our code, and to store those changes. This is known as version control. When used with GitHub, git allows us to keep track of our code in publicly accessible repositories.
$ git init Initializes new repository
$ git add . Adds the current directory to git. This automatically includes all subdirectories. You can accomplish the same task with $ git add filename. When you run this command, your files are added to the staging area.
$ git status Tells you which files are in the staging area.
$ git commit -m “initial commit” Tells git you want to commit, or keep, your changes. You can put any message you like inside the quotation marks. Note: Git commits are local to your machine. Committing to Git is not the same as pushing to GitHub.
$ git log Shows you a list of your commit messages.
Pushing to GitHub
To push your commit to GitHub, you need to create a repository for your project, or push to an existing repository. Once your repository is created, you should see several helpful commands and links in the repository. In existing repositories, the link you need will be in the right sidebar. These will be helpful in pushing your content from git to GitHub.
$ git remote add origin https://<link in repository> followed by $ git push -u origin master. This pushes your code to the chosen repository.
You should now see your code in your GitHub repository.
- PM Career Story - April 28, 2022
- How to Transition into Product Management - December 26, 2017
- What I’ve Learned in My First Few Months as a Product Manager - October 14, 2015