-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added files for git automation using terminal #36
Open
PIYUSH-MISHRA-00
wants to merge
1
commit into
torvalds:master
Choose a base branch
from
PIYUSH-MISHRA-00:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#! /bin/bash | ||
|
||
### Git automation script for automating git clone, push and pull ### | ||
### Created by PIYUSH-MISHRA-00 ### | ||
|
||
while : | ||
do | ||
echo | ||
echo "Which Git operation you want to perform ?" | ||
echo | ||
echo "GitHub username: $username" | ||
echo "Local repository name: $local_repo" | ||
echo "Remote repository name: $remote" | ||
echo "The default branch you want to work with: $branch" | ||
echo "GPG key value: $GPG" | ||
echo | ||
echo -e "\t(0) Configure (configures the script for continuous uses)" | ||
echo -e "\t(1) Clone" | ||
echo -e "\t(2) Pull" | ||
echo -e "\t(3) Push" | ||
echo -e "\t(4) Exit" | ||
echo -n "Enter your choice [0-4]: " | ||
|
||
read choice | ||
|
||
case $choice in | ||
|
||
0) echo "Enter the values for future use of the script..." | ||
echo | ||
echo "Enter GitHub username: " | ||
read username | ||
export username | ||
echo "Your username is: $username" | ||
echo | ||
echo "Local repository name: " | ||
read local_repo | ||
export local_repo | ||
echo "Your local repository name is: $local_repo" | ||
echo | ||
echo "Remote repository name: " | ||
read remote | ||
export remote | ||
echo "Remote repository name is: $remote" | ||
echo | ||
echo "The default branch you want to work with: " | ||
read branch | ||
export branch | ||
echo "The default branch you want to work with: $branch" | ||
echo | ||
echo "GPG key value is: $GPG" | ||
echo | ||
echo "GPG key id for signed commits(leave blank if you don't want signed commits)" | ||
read GPG | ||
export GPG | ||
echo "GPG key value is: $GPG" | ||
echo | ||
;; | ||
|
||
1) echo "Cloning from GitHub" | ||
echo | ||
echo "Enter the repository https url: " | ||
read clone_url | ||
git clone $echo $clone_url;; | ||
|
||
2) echo "Pulling from GitHub" | ||
echo | ||
echo "Enter the repository https url: " | ||
read pull_url | ||
echo | ||
echo $pull_url | ||
echo | ||
while : | ||
do | ||
echo "Which type of Git Pull you want ?" | ||
echo -e "\t(1) Merge (the default strategy)" | ||
echo -e "\t(2) Rebase" | ||
echo -e "\t(3) Fast-forward only" | ||
echo -e "\t(4) Return to main menu" | ||
echo -n "Enter your choice [1-4]: " | ||
read pull_choice | ||
case $pull_choice in | ||
1) | ||
git config pull.rebase false | ||
git pull $echo "$pull_url";; | ||
2) | ||
git config pull.rebase true | ||
git pull $echo "$pull_url";; | ||
3) | ||
git config pull.ff only | ||
git pull $echo "$pull_url";; | ||
4) | ||
break | ||
;; | ||
*) | ||
echo "Invalid operation" | ||
;; | ||
esac | ||
done | ||
;; | ||
|
||
3) echo "Pushing to GitHub" | ||
declare -A map | ||
|
||
map[$echo"$local_repo"] = $echo"$remote" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove spaces around |
||
|
||
git config --global user.name $echo"$username" | ||
git config --global user.signingkey $echo$GPG | ||
git init | ||
git add . | ||
echo "Enter Commit message: " | ||
read message | ||
git commit -m $echo "$message" | ||
echo "Enter Tag name: (Press enter if you want to skip the tag name)" | ||
read tag | ||
echo "Enter Tag message: (Press enter if you want to skip the tag message)" | ||
read tag_message | ||
git tag -a $echo$tag -m "$echo$tag_message" | ||
git tag -n | ||
|
||
for i in "${!map[@]}" | ||
do | ||
git remote add $i https://github.com/$echo$username/${map[$i]}.git | ||
git push -u $i $echo$branch | ||
done | ||
|
||
git push;; | ||
|
||
4) echo "Quitting..." | ||
exit | ||
;; | ||
|
||
*) echo "Invalid operation" | ||
;; | ||
|
||
esac | ||
done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quotes would be preferred to prevent globbing/word splitting, like so:
git clone "$echo" "$clone_url";;