1. Add a project, fork a repository, then clone
git clone <URLFROMGITHUB>
2. Connect to the original repository, and add a remote connection, and name it `upstream`
git remote add upstream <URLFROMGITHUB>
3. Add branch, and choose the new branch to avoid conflicts with the master. When we add the new branch to complete our functions, then merge it into the master
git branch <BRANCHNAME>
git checkout <BRANCHNAME>
4. After making changes on our branch, Need to record
git status
git add -A
git commit -m "description"
5. Switch to master and get all updates, then merge the updates on master to the new branch and push to the remote branch
git checkout master
git pull origin master
git checkout <BRANCHNAME>
git rebase -i master
git push --set-upstream origin <BRANCHNAME>
6. Before each code submission, you need to get the latest code to prevent overwriting others' code
git fetch --dry-run
git pull
7. Enter the github project page, Create merge request
8. After the branch is accepted and merged, the branch is merged locally Enter master, delete branch, perform the same operation remotely
git checkout master
git merge <BRANCHNAME>
git branch -d <BRANCHNAME>
git push <REMOTENAME> --delete <BRANCHNAME>
//Other common commands
git init //Init a file The folder is initialized as a git warehouse
git diff //View the modifications to the file
git remote add <REMOTENAME> //Add a remote link
git remote set-url <REMOTENAME> //Set a remote address
git remote add <REMOTENAME> <URL> //Add remote link with address
git remote -v //View all remote
git pull <REMOTENAME> <BRANCHNAME> //Receive updates from a remote (default master branch)
git push <REMOTENAME> <BRANCHNAME> //Submit code to the specified remote (default master branch)
git branch -M <NEWBRANCHNAME > //Modify the current branch name
git branch //List all branches
git clone <URLFROMGITHUB>
2. Connect to the original repository, and add a remote connection, and name it `upstream`
git remote add upstream <URLFROMGITHUB>
3. Add branch, and choose the new branch to avoid conflicts with the master. When we add the new branch to complete our functions, then merge it into the master
git branch <BRANCHNAME>
git checkout <BRANCHNAME>
4. After making changes on our branch, Need to record
git status
git add -A
git commit -m "description"
5. Switch to master and get all updates, then merge the updates on master to the new branch and push to the remote branch
git checkout master
git pull origin master
git checkout <BRANCHNAME>
git rebase -i master
git push --set-upstream origin <BRANCHNAME>
6. Before each code submission, you need to get the latest code to prevent overwriting others' code
git fetch --dry-run
git pull
7. Enter the github project page, Create merge request
8. After the branch is accepted and merged, the branch is merged locally Enter master, delete branch, perform the same operation remotely
git checkout master
git merge <BRANCHNAME>
git branch -d <BRANCHNAME>
git push <REMOTENAME> --delete <BRANCHNAME>
//Other common commands
git init //Init a file The folder is initialized as a git warehouse
git diff //View the modifications to the file
git remote add <REMOTENAME> //Add a remote link
git remote set-url <REMOTENAME> //Set a remote address
git remote add <REMOTENAME> <URL> //Add remote link with address
git remote -v //View all remote
git pull <REMOTENAME> <BRANCHNAME> //Receive updates from a remote (default master branch)
git push <REMOTENAME> <BRANCHNAME> //Submit code to the specified remote (default master branch)
git branch -M <NEWBRANCHNAME > //Modify the current branch name
git branch //List all branches