Git user guide for collaboration
Solo
- git clone [repo]
- Open folder and work
change repo
- git status
- git add .
- git commit -m “commit messgae”
- git push
- [next time, if any change] git pull
merge changes from main
- git checkout main
- git pull
- git checkout [your_branch]
- git merge main
- git push
Preparation for git
- Download git
- Prepare personal token to access Github from command line
Access your Github locally using a token
- Set email and user neam git config —global user.name “” git config —global user.email “” git config -1
- Use token to login
- Clone a repo
- Enter user name and token
Preparation for collaboration
- Create a main repo under a user
- For every contributor, fork the repo into their own account
- In their local computer, use “git clone http …” to copy the repo from the cloud.
- Set origin, “git remote add origin ”
- Set upstream, “git remote add upstream ”
Before work
- Run “git status” to check all work are committed
- If not, run “git add .” & “git commit -m “” “ to clear workspace
- Run “git fetch upstream/main” to download the newest version (sometimes main should be changed into master)
- Run “git merge upstream/main” to update local file.
- You can use “git pull” to update from your own repo
- Ready to work
After work
- Run “git add .” To add all changes to workspace
- Run “git commit -m “” “ to commit the changes with a reference message
- Run “git push origin main” to upload your local change to your repo in your account
- If the main repo has another update, you should run “fetch & merge” before you “push”
- Login to Github and start a pull request.