Skip to content

Latest commit

 

History

History
96 lines (73 loc) · 2.96 KB

File metadata and controls

96 lines (73 loc) · 2.96 KB

git

Updating a repository from the command-line.

References

Cloning a repo

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY

References:

Commits

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

Branches allow you to develop outside the main branch. This is good for experimenting and/or 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:

Update repository

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

Pull requests

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request