Github is a platform for hosting and collaborating on Git repositories.
Melacak perubahan source code
kolaborasi
Jenis VCS
git
cvs (concurent version system)
subversion
Repository services
github
gitlab
bitbucket
Preparation
git
vs code
terminal
ls
pwd(print working directory)
cd
cd ..
cd ~
mkdir new\ folder
mkdir src/img
ls --help
Menginstall di MacOS
check git
git
configuration git
git config --global user.name "github_username"
git config --global user.email "email_address"
git init
git status
git
Configure your local Git installation to use your GitHub credentials by entering the following:
git config --global user.name "github_username"
git config --global user.email "email_address"
git config --global init.defaultBranch main
Note: Replace github_username and email_address with your GitHub credentials.
git update-git-for-windows
Sometimes it may be a good idea to exclude files from being tracked with Git. This is typically done in a special file named .gitignore . You can find helpful templates for .gitignore files at https://github.com/github/gitignore.
List of the files to ignore push on github: https://gitignore.io/
git init : This will create a .git repository in your project.
git add : This will add everything from the project folder to the staging area.
git add*.html: This would add all your .html files to the staging area.
git add filename.extension: Replace “filename. extension” to the file you want to add like “index.html.”
git status: This will show us what has already been added to the staging area and which files have been altered, and need to be moved to the staging area.
git commit -m “Description”: This will take the files present in your staging area and subsequently commit them to the local repository. You would have to describe your commit in brief details like “fixed bug because the user name wasn’t getting updated.”
git branch <branch-name>: It should be able to create a new branch.
git checkout <branch-name>: This command is supposed to be used for switching the branch.
git push origin <branch-name>: This should be able to push your local repository to your remote repository.
git clone <repo-url>: If you do not have your project on your system, this should allow you to clone the project within the directory you are working with.
git pull <remote> <branchname>: If you are supposed to be working on the same codebase with other people, this command should allow you to pull the latest version from a remote repository and update the local version.
git config: global user.name “Name” git config – global user.email “Email” – This should be able to set up your information that is to be utilized every time you shall be conducting a commit. This would only have to be done one time when you install Git.
Training
Training menggunakan GitHub: (Versi Indonesia)
https://training.github.com/downloads/id/github-git-cheat-sheet/
GitHub Training (English Version)
https://training.github.com/downloads/github-git-cheat-sheet/
Ebook
Q and A
error: src refspec main does not match any error: failed to push some refs to <url>?
This is an unpleasant result of the master vs main controversy.
Your local GIT client created a default branch called master (when you initialized the repo with git init), but the remote repository on GitHub has no master - instead the default branch is called main.
Solution A - if you want to name the branch master. Run:
git push -u origin master instead of git push -u origin main
Or Solution B - if you want to name the branch main. Run:
git checkout -B main before git push -u origin main
Push tanpa login
Git menggunakan Visual Studio Code
git: an open source, distributed version-control system
commit: a Git object, a snapshot of your entire repository compressed into a SHA
branch: a lightweight movable pointer to a commit
clone: a local version of a repository, including all commits and branches
remote: a common repository on GitHub that all team members use to exchange their changes
fork: a copy of a repository on GitHub owned by a different user
pull request: a place to compare and discuss the differences introduced on a branch with reviews, comments, integrated tests, and more
HEAD: representing your current working directory, the HEAD pointer can be moved to different branches, tags, or commits when using git checkout