Git version control
Workflow
- Go to the repositry, and go to tab Issues.
- Press New issue. Fill in Title, Comment, Assignees, Labels, etc. Then Submit new issue.
- Go to your local command, clone the repository.
git clone https://github.com/zcemycl/learnGit.git
- Create a branch to solve the issue. Go to branch, and start editing.
git branch dev master
git branch -a
git checkout dev
- Commit your branch to github. This will also create pull/merge request.
git add .
git commit -m "some messages"
git push origin dev
- Go back to github webpage again. View Pull requests tab.
- Press Compare & pull request button. This will create a new pull request.
- Now assign Reviewers, Assignees, Labels, branch to merge / be merged. Press Create pull request.
- 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.
- Sometimes, if you click pull requests, there are some conflicted files look as follows,
<<<<<<<<<<<< branch1
line 1
===================================
line 1'
>>>>>>>>>>>> master
- Just delete online to the follow format to resolve conflicts,
line 1
- Once it is done, press Merge pull request. You can close it as well.
- Get back to Issues, link the Issues to the respective Pull requests. You can as well delete branch.
- Since the branch is closed online, you need to update your branches locally.
git fetch
git pull
- Delete your branch which is unnecessary anymore.
git branch -D dev
git remote prune origin
- To cache your username and token, you can use,
git config --global credential.helper manager-core
- Use ssh key to control repo,
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
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,
- Software can be modified, used commercially, and distributed.
- Software can be modified and used in private.
- A license and copyright notice must be included in the software.
- Software authors provide no warranty with the software and are not liable for anything.
Steps to create one,
- In your repo root, click on Create new file.
- Name the file 'LICENSE'.
- Click on Choose a license template.
- Choose any license which fits you the best.
- Click on Review and Submit
- Commit the file.
Updates
- Deprecation Notice: Basic authentication using a password to Git is deprecated and will soon no longer work.
Other commands
- Reset add and commit by -1 step.
git reset --soft HEAD~1
References
- GitHub zcemycl/learnGit
- How open source licenses work and how to add them to your projects
- Markdown License badges
- How To Undo Last Git Commit
- Where to store my Git personal access token?
- SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)