Follow these commands π
git --version
Register your information in Git
git config --global user.name "μ΄λ¦"
git config --global user.email "μ΄λ©μΌ"
# Initialize git
git init
git status
git add filename / directory name / .
git commit -m "Message"
git log
<commit-hash>
with the hash value of the commit shown in the git log
.git checkout <commit-hash>
# Create branch
git branch <new-branch-name>
# Create branch & Switch into branch
git checkout -b <new-branch-name>
git branch
ex) If you merge Branch B to Branch A (or main)
git merge <branch name>
git branch -d <branch-name>
git remote -v
git remote add origin https://github.com/<your-username>/<your-repo-name>.git
git clone <github-repo-link>
Push to main / branch
Upload commit to github repository
(main) git push origin main
(branch) git push origin λΈλμΉ μ΄λ¦
Check the branch if the following error occurs
* You should push to master branch
git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Judy-Choi/41-minjoo.git'
Pull Request
If you updated the master branch through Pull Request, the local repository will now have different contents from the master in GitHub. Then you can use the git pull command to reflect the latest code from remote to your local repository.
We named the GitHub remote repository link origin, so you can get the master branch contents of GitHub repo through the command below.
git pull origin master