- What is Git?
- What is Github?
- Installation?
- Setting up git in your device
- Setting up a local repo
- Creating a remote repo
- git-remote
- Staging changes to remote
- git-branches
- git-rebase
- How to contribute to open-source projects
- Working with Github Actions
- Cheat-Sheet
Feel free to reach us in case of any queries. We are always happy to help you one bit at a time🐱💻
Git is the free and open source distributed version control system that's responsible for everything GitHub related that happens locally on your computer.
GitHub is a code hosting platform for collaboration and version control. GitHub lets you (and others) work together on projects.
With platform specific installers for Git, GitHub also provides the ease of staying up-to-date with the latest releases of the command line tool while providing a graphical user interface for day-to-day interaction, review, and repository synchronization.
-
GitHub for Windows https://windows.github.com
-
GitHub for Mac https://mac.github.com
For Linux and Solaris platforms, the latest release is available on the official Git web site.
- Git for All Platforms http://git-scm.com
Configuring user information used across all local repositories
git config --global user.name “[firstname lastname]”
[set a name that is identifiable for credit when review version history]
git config --global user.email “[valid-email]”
[set an email address that will be associated with each history marker]
git config --global color.ui auto
[set automatic command line coloring for Git for easy reviewing]
- Open Terminal.
- Change the current working directory to your local project.
- Initialize the local directory as a Git repository.
git init -b main
- Add the files in your new local repository. This stages them for the first commit.
git add .
- Commit the files that you've staged in your local repository.
git commit -m "First commit"
-
At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
-
In Terminal, add the URL for the remote repository where your local repository will be pushed.
git remote add origin <REMOTE_URL>
- Push the changes in your local repository to GitHub.
git push origin main
Versioning file removes and path changes
git rm [file]
[delete the file from project and stage the removal for commit]
git mv [existing-path] [new-path]
[change an existing file path and stage the move]
git log --stat -M
[show all commit logs with indication of any paths that moved]
Retrieving updates from another repository and updating local repos
git remote add [alias] [url]
add a git URL as an alias
git fetch [alias]
fetch down all the branches from that Git remote
git merge [alias]/[branch]
merge a remote branch into your current branch to bring it up to date
git push [alias] [branch]
Transmit local branch commits to the remote repository branch
git pull
fetch and merge any commits from the tracking remote branch
It solves the same problem as git merge. Both of these are used to add changes from one branch to another. The only difference is
git checkout -b feature-branch
[add commits to your feature branch]
git rebase master
Github Actions Source
GitHub Actions make it easy to automate all your software workflows. Github Actions let you build, test, and deploy your code right from GitHub. You can also assign code reviews, manage branches, and triage issues the way you want with actions.
Every Github action required a .yml
file.
-
Workflow: The workflow is an automated procedure that you add to your repository. Workflows are made up of one or more jobs and can be scheduled or triggered by an event.
-
Events: An event is a specific activity that triggers a workflow.
-
Jobs: A job is a set of steps that execute on the same runner. By default, a workflow with multiple jobs will run those jobs in parallel.
-
Steps: A step is an individual task that can run commands in a job. A step can be either an action or a shell command.
- How to edit a git commit?
git commit --amend
- Better ways to see git log?
git log --oneline
git log --graph
- I want to check a PR locally before mergin
git fetch origin pull/$ID/head:$BRANCHNAME && git checkout $BRANCHNAME
- I want to select specific commits from a PR
git cherry-pick commit-hash
- How do I add a remote?
git remote add [name | example: origin,upstream] "url of repo"
- How do I view all my remotes?
git remote -v
- Can I remove a remote?
git remote rm origin,upstream etc
- How do I pull from remote?
git pull origin branch-name
- I staged my changes by mistake. What can I do now?
git reset
- I am trying to pull but getting "fatal: Not possible to fast-forward, aborting." error
git pull -f origin 'branch-name'