Updating a repository from the command-line.
"I really never wanted to do source control management at all and felt that it was just about the least interesting thing in the computing world (with the possible exception of databases ;^), and I hated all SCM’s with a passion." -- Linus Torvalds, creator of git
- git book, 2nd edition -- git-scm.com
- about git -- branching
- git history
Section 1.5 in the onlinen book has guidance on installingn command-line git. All of Chapter 1 in the online book is worth reading if you want background on git.
- 1.5 Installing git -- git-scm.com
- Note also: 1.4 Getting Started -- The Command Line
These tutorials describe advanced usage of git and github, which we'll use later in the course.
- github starter course
- atlassian git tutorials -- atlassian.com
- Some very good tutorials
- Begginner guide
- Setting up a repository -- pretty good
- Collaborating -- later in the course
- github cli -- github.com
- This -- the github CLI -- is NOT the same as "git" (I don't use it)
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
Reference:
After you make a change in to your local repository, you commit the changes and add a message
$ git commit . -m "I made a small but super-important change to such and such."
To check the status of current repo
$ git status
To review the commit history
$ git log
To checkout a previous commit
$ get checkout <tag/branch/commit id>
To reset to a previous commit (and lose everything since then!)
$ get reset --hard <tag/branch/commit id>
References:
Branches allow you to develop outside the main branch. This is good for experimenting and collaborating.
$ git branch- list branches, including current branch
- default branch is usually "main"
- if you haven't created any branches, that'll be the only one
$ git branch demo- create the "demo" branch
$ git checkout demo- switch to the demo branch
- You need to specify the upstream for the branch before you can "push" or "pull"
- We're not going to be using the workflow for branches, at least not now.
- To merge a branch
$ git commit . -m "I made a such-and-such a change" $ git checkout main $ git merge demo - To delete a branch after merging
$ git branch -d branch
- To delete a branch without merging
$ git branch -D branch
References:
- git branch -- git-scm.com
- Git branching -- git-scm.com
- About branches
- Working with branches
You update the repository by "pushing to origin". This is okay if you're the only one working on the project.
$ git push origin main
If you've made a change, then you need first to commit
$ git commit . -m "I've made a such-and-such a change"
$ git push origin main
Creating a pull request -- github.com