Git version control


Workflow

  1. Go to the repositry, and go to tab Issues.
  2. Press New issue. Fill in Title, Comment, Assignees, Labels, etc. Then Submit new issue.
  3. Go to your local command, clone the repository.
  4. 
    git clone https://github.com/zcemycl/learnGit.git
        
  5. Create a branch to solve the issue. Go to branch, and start editing.
  6. 
    git branch dev master
    git branch -a
    git checkout dev
        
  7. Commit your branch to github. This will also create pull/merge request.
  8. 
    git add .
    git commit -m "some messages"
    git push origin dev
        
  9. Go back to github webpage again. View Pull requests tab.
  10. Press Compare & pull request button. This will create a new pull request.
  11. Now assign Reviewers, Assignees, Labels, branch to merge / be merged. Press Create pull request.
  12. At Pull requests tab, the reviewer can comment, check lines changed in Files changed, highlight the changed code to comment, etc. This is called code review process.
  13. Sometimes, if you click pull requests, there are some conflicted files look as follows,
  14. 
    <<<<<<<<<<<< branch1
    line 1 
    ===================================
    line 1'
    >>>>>>>>>>>> master
        
  15. Just delete online to the follow format to resolve conflicts,
  16. 
    line 1 
        
  17. Once it is done, press Merge pull request. You can close it as well.
  18. Get back to Issues, link the Issues to the respective Pull requests. You can as well delete branch.
  19. Since the branch is closed online, you need to update your branches locally.
  20. 
    git fetch
    git pull 
        
  21. Delete your branch which is unnecessary anymore.
  22. 
    git branch -D dev
    git remote prune origin
        
  23. To cache your username and token, you can use,
  24. 
    git config --global credential.helper manager-core
        
  25. Use ssh key to control repo,
  26. 
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    # copy ssh public key to github: Icon → Settings → SSH and GPG Keys → New SSH Key
    git clone ssh_path
    ssh -T git@github.com
        
  27. 
        

Git Ignore

To ignore some files' changes, and to avoid uploading them. Create a filename called .gitignore,


data/*
.ipynb_checkpoints/*
*.swp
    

Git Attributes

To control the display of languages in the repo, create a file named .gitattributes,


* linguist-vendored
*.html linguist-vendored=false
*.js linguist-vendored=false
*.css linguist-vendored=false
    

LICENSE

The Open Source Initiative (OSI) is a non-profit corporation with global scope formed to educate about and advocate for the benefits of open source and to build bridges among different constituencies in the open source community.

Most open source licenses include the following,

  1. Software can be modified, used commercially, and distributed.
  2. Software can be modified and used in private.
  3. A license and copyright notice must be included in the software.
  4. Software authors provide no warranty with the software and are not liable for anything.

Steps to create one,

  1. In your repo root, click on Create new file.
  2. Name the file 'LICENSE'.
  3. Click on Choose a license template.
  4. Choose any license which fits you the best.
  5. Click on Review and Submit
  6. Commit the file.

Updates

  1. Deprecation Notice: Basic authentication using a password to Git is deprecated and will soon no longer work.

Other commands

  1. Reset add and commit by -1 step.
  2. 
    git reset --soft HEAD~1
        
  3. 
        

References


  1. GitHub zcemycl/learnGit
  2. How open source licenses work and how to add them to your projects
  3. Markdown License badges
  4. How To Undo Last Git Commit
  5. Where to store my Git personal access token?
  6. SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)