All Projects → msaaddev → git-commands-workflows

msaaddev / git-commands-workflows

Licence: MIT License
🚀 All the git commands and workflows you need to know

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to git-commands-workflows

git-remind
Never forget to git commit and push
Stars: ✭ 86 (+72%)
Mutual labels:  git-workflow, git-commit, git-push
linux-cheatsheet
This is Day to Day Work Linux Cheatsheet for Software Engineers.
Stars: ✭ 26 (-48%)
Mutual labels:  commands, cheatsheet
hackthebox
Notes Taken for HTB Machines & InfoSec Community.
Stars: ✭ 286 (+472%)
Mutual labels:  commands, cheatsheet
Gitreflow
Reflow automatically creates pull requests, ensures the code review is approved, and squash merges finished branches to master with a great commit message template.
Stars: ✭ 1,488 (+2876%)
Mutual labels:  workflow, git-workflow
The-Learning-Documentation-Project
This documentation is about the new learning(s) and issue(s) resolvings on different aspects of academic, professional and personal thoughts. It includes(or/with links): Research topics(& resources), Programming(issues and code), Advanced Linux commands, Networking commands, bash script command utilization, Linux packages(& scripts), Machinine l…
Stars: ✭ 27 (-46%)
Mutual labels:  commands, commands-cheat-sheet
Asciidots-Cheat-Sheet
My personal Asciidots Cheat Sheet in .jpg .odt .pdf .png and obviously in .txt
Stars: ✭ 17 (-66%)
Mutual labels:  commands, cheatsheet
git-emojis-hook
Simple git hook to provide strong guidelines for commit message with emojis
Stars: ✭ 46 (-8%)
Mutual labels:  git-workflow, git-commit
OSCP-Prep
Contained is all my reference material for my OSCP preparation. Designed to be a one stop shop for code, guides, command syntax, and high level strategy. One simple clone and you have access to some of the most popular tools used for pentesting.
Stars: ✭ 33 (-34%)
Mutual labels:  bash-script
PS4-Cheat-List
List of PS4 cheat codes / offsets found for either PS4Cheater or NetCheatPS4
Stars: ✭ 69 (+38%)
Mutual labels:  cheatsheet
cli
Aplus Framework CLI Library
Stars: ✭ 104 (+108%)
Mutual labels:  commands
gitmoji-plugin
Choose the right emoji emoticon for git commit, make git log commit more interesting.
Stars: ✭ 110 (+120%)
Mutual labels:  git-commit
tuterm
A better way to learn CLI programs.
Stars: ✭ 22 (-56%)
Mutual labels:  bash-script
concise-cheat-sheets
Cheat Sheets for programming languages and tools
Stars: ✭ 98 (+96%)
Mutual labels:  cheatsheet
oscp
My notebook for OSCP Lab
Stars: ✭ 22 (-56%)
Mutual labels:  cheatsheet
WeiboPictureWorkflow
微博图床 Alfred Workflow,警告:微博修改了登录方式,此 workflow 暂时不能用了,何时修复未定,推荐使用 iPic
Stars: ✭ 23 (-54%)
Mutual labels:  workflow
l2cu
L²CU: LDraw Linux Command line Utility
Stars: ✭ 14 (-72%)
Mutual labels:  bash-script
PXESetupWizard
PXE Setup Wizard. Netboot Debian, Ubuntu, System Rescue CD, FreeDOS and more.
Stars: ✭ 96 (+92%)
Mutual labels:  bash-script
Stamp-Craft
Plugin for adding timestamp to filenames.
Stars: ✭ 28 (-44%)
Mutual labels:  workflow
JJMumbleBot
A plugin-based All-In-One mumble bot solution in python 3.7+ with extensive features and support for custom plugins.
Stars: ✭ 40 (-20%)
Mutual labels:  commands
laravel-livewire-ui
Laravel Livewire UI, Auth, & CRUD starter kit.
Stars: ✭ 92 (+84%)
Mutual labels:  commands

git-commands-workflows

The git commands & workflows you need to know to work with git and automate your regular commands.


Initialization

# paste this in your terminal to change your current working directory to the project directory
cd your_project_path

# initialize git
git init

Commands

⚡️ The repetitive commands that I (and everyone else) use regularly.

# connect the remote GitHub repo with your local project
git remote add origin [github-repo-url]

# see untracked files
git status

# add all untracked files to the staging area
git add .

# commit the tracked files of the staging area
git commit -m "commit-msg"

# push all the changes to the GitHub
git push -u origin master

🏗 Git Setup if you have never used git before.

# configure git with your github username
git config --global user.name "your_github_username"

# configure git with your github email (email you used to sign up on GitHub)
git config --global user.email "[email protected]"

🎩 Clone a repository in your computer.

# clone a repo
git clone [repo_url]

🌲 The git commands you need to know to work with branches.

# list all branches
git branch

# create a new branch
git branch [branch_name]

# checkout to the new branch
git checkout [branch_name]

# 	OR

# create AND checkout to the new branch
git checkout -b [branch_name]

# pushing the new branch on GitHub
git push origin [branch_name]

# delete a branch locally
git branch -d [branch_name]

# delete a branch on GitHub
git push origin -d [branch_name]

# pulling changes from some other branch
git pull origin [branch_name]

# merge a branch with the current active branch
git merge [branch_name]

# merge a branch to some defined branch
git merge [source_branch] [target_branch]

📚 Stashing untracked changes — It saves all the new untracked changes and rewind your repo to the last commit.

# stash the untracked changes
git stash

# pop an existing stack
git stash apply stash@{stash_number}

# list all stashes
git stash list

# delete all saved stashes
git stash clear

🍒 Pulling all the new changes from the remote repository on GitHub

# pull changes from master branch
git pull origin master

# pulling changes from some other branch
git pull origin [branch_name]

🎯 Keep your GitHub forked repo in sync with the original repository.

# STEP #1: show URLs of remote repositories when listing your current remote connections
git remote -v

# STEP #2: add upstream
git remote add upstream [source-repo-url]

# STEP #3: fetching all the new changes from the main repository
git fetch upstream

# STEP #4: merging the new changes from the original repo to your forked local repo
git merge upstream/master

# STEP #5: pushing the new changes of the forked local repo to the GitHub
git push origin master

Note: Replace master with main if your primary branch is main.


Workflows

Open your .zshrc or .bashrc file. It is located in your Home directory. Paste the following shellcode there.

# Keep your GitHub forked repo in sync with the original repository with master as the primary branch
function fetchremotems() {
	git fetch upstream &&
	git merge upstream/master &&
	git push origin master
}

# Keep your GitHub forked repo in sync with the original repository with main as the primary branch
function fetchremotemn() {
	git fetch upstream &&
	git merge upstream/main &&
	git push origin main
}

# create new branch and checkout to it
function gcb() {
	git checkout -b "${1}"
}

# checkout to a branch
function gch() {
	git checkout "${1}"
}

# push changes to another branch
function gbp() {
	git push origin "${1}"
}

# add, commit, push changes to github
function gacp() {
	git add . &&
	git commit -m "${1}" &&
	git push
}

# aliases
alias gi='git init'
alias gs='git status'
alias ga='git add '
alias gaa='git add .'
alias gc='git commit -m '
alias gp='git push'
alias gra='git remote add origin '
alias gpm='git push -u origin master'

# create YOUR own git workflows
function [functionName]() {
    # commands to execute when function is called
    # if there are more than one commands, use && between them
    # to use the first output from the terminal, use "${1}"
}

🚀 Usage

Fetching changes from the original repo to your forked repo.

cd your_project_path

# do this only once in every forked local repo to add upstream
git remote add upstream [source-repo-url]

# write the following in the terminal – primary branch: master – whenever you need to fetch the changes
fetchremotems

# write the following in the terminal – primary branch: main – whenever you need to fetch the changes
fetchremotemn

Usage of the rest of the workflows.

# To create a new branch and also to checkout to it
gcb [branch_name]

# To checkout to an existing branch
gch [branch_name]

# To push changes to another branch
gbp [branch_name]

# To add, commit and push changes to the github
gacp "commit-msg"

# initialize git
gi

# check status
gs

# stage untracked file
ga [file_name]

# stage all untracked files
gaa

# commit the changes
gc "commit-msg"

# connect remote repo to the local repo
gra [repo-link]

# push changes to master
gpm

👨🏻‍💻 Contributing

Feel free to add your git workflows in the repository. Just make sure you first read the contributing guidelines before making a PR.

⚡️ Other Projects

I have curated a detailed list of all the open-source projects I have authored. Do take out a moment and take a look.

🔑 License & Conduct

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].