I am currently using flutter in Android studio and was wondering how to link a project to a private repo in android studio?
Btw this is a condensed self answer to myself.
cd <project folder>
git init
git add .
git remote add origin https://github.com/USERNAME/project.git
git fetch origin
git commit -m "My first commit"
git push -u origin master
Then in android studio
VCS -> Git -> Push
Related
This question already has answers here:
How do I add files and folders into GitHub repos?
(12 answers)
Closed 2 years ago.
I have 2 Android App projects that I want to add to the same GitHub repo. I wish to create 2 folders in the repo and upload the app files to the corresponding folders. Any way that I can do it using Git CLI and Git Bash rather than uploading the files manually?
First of all,create a new repository from the github.
Then copy the repository ssh url or https url for the repository.
After that cd to the main directory such that the two sub folders are inside it
Then type the following in the terminal -
git init
git commit -m "first commit"
git remote add origin [url-for-github-repo]
git push -u origin master
If Your github url is git#github.com:AnishAralikatti/Android.git
git init
git commit -m "first commit"
git remote add origin git#github.com:AnishAralikatti/Android.git
git push -u origin master
I have run below commands in android studio terminal on 'development' branch.
git rm -r --cached .
git add .
git commit -m "commitXYZ"
after that when I checkout to another branch and coming back to 'development' branch again, only gitignore files is showing not other modules like 'app' etc
Please see the attached screenshot.
How to add one repository to another repository on Github? I have one project workspace XXX and i have my own created repository YYY somewhere else, so i want to add that repo to that blank repo created.
Here is simple way I can think of
Clone the xxx repository
open it and delete .git folder
open terminal and type git init
type command git remote add origin GIT_URL_OF_YYY
add , commit and push
You could do this with simple two steps :
clone {current}
push {new}
A. clone {current} git clone
create local directory
open terminal
git clone ssh://john#example.com/path/to/my-project.git
cd my-project
B. push {new} git push <remote> <branch>
git remote add origin example.com/path/to/my-project.git
git push origin master
you may face an error of repo{s} timing, so.. you may need to fore pushing
and you may face some other problems then you will just run git add . git commit -m "first lanuch" git push -u origin master
I have three branches, the main branch, the development branch and the new_feature branch.
The problem is I accidently set my first commit (initial commit)on the development branch.
Screenshot of my problem:
Full overview of my branches:
Question: How do I change it to the main branch?
As you haven’t merge remote branches (origin/development and origin/new_feature) into local repo. So there are two situations
Don’t need remote changes. Follow these steps:
Create a new “initial commit”. git checkout master, git checkout --orphan master1 and then git commit
Rebase development branch on it. git checkout development and git rebase master1 (if there has conflict file, you use to use git add filename and git rebase --continue).
Delete master and new_feature branch. git branch -D master and git branch -D new_feature
Rename branch. git branch -m master1 master, git checkout master and git branch new_feature
Force push to remote. git push -f --all
Need remote changes. Follow below steps:
Merge remote changes to local. git checkout development, git merge origin/development, git checkout new_feature, git merge origin/new_feature
Create a new “intial commit”. git checkout master, git checkout --orphan master1 and then git commit
Rebase development branch on it. git checkout developmen and git rebase master1
Rebase new_feature branch on it. git checkout new_feature and git rebase master1
Rename master branch. git branch -D master and git branch -m master1 master
Force push to remote. git push -f --all
You can merge your develop branch with your master branch or use the cherry-pick command from your master branch for retrieving your initial commit.
git push -u origin development//(push it up to development)
git checkout main //checkout local main branch
git pull origin development //Pull latest from remote development branch into main
git add -A
git commit -m "get latest from development"
git push -u origin //push up to main
You can rename your development branch.
$ git checkout development # checkout development
$ git checkout -b development-backup # backup development branch
$ git branch -D master # delete your current local master
$ git branch -m development master # rename development -> master
$ git checkout master # checkout master
$ git push -f origin master # force push, update remote master
I have a project in android studio that i want to commit to a gitlab repository. I have a link for this repository. What do i need to do, step for step, to add this project to said repository?
First you have to guarantee that this project is already a git repository on your local machine.
You can do this by checking if there's a folder .git in the directory. If there's none, do the following command:
# create a git repository on the current directory
git init
After that you need to make your repository point to gitlab
git remote add origin "url from gitlab"
Add files for your initial commit
git add -A
Commit the files
git commit -m "your initial commit message"
Push all the files to the remote(gitlab)
git push -u origin master
More information of each command can be found typing:
man git command
# example
man git push
For using gitlab when you have ssh keys and also your ssh key have passphrase, you have to follow instructions as follow (don’t forget to upload your public key to gitlab)(also you must use a private key which its format is openssh):
Have your project folder and its files.
Have Git Bash installed on your system.
Using git bash, go to your project directory.
git config --global user.name "your-name"
git config --global user.email "your-email-address"
git init
ssh-agent bash -c 'ssh-add “private-key-local-address”; git remote
add origin “online-repo-address”’ (will be asked for passphrase)
git add .
git commit -m “initial commit”
ssh-agent bash -c 'ssh-add “private-key-local-address”; git push
-u origin master' (will be asked for passphrase)
For further commits, you can commit changes in android studio and then repeat step 10 to push them to gitlab servers.