git remote set-url origin https://github.com/rimatla/repo_name.git
git remote add origin https://github.com/username/repo_name.git
git remote show origin
[CakePHP](http://www.cakephp.org) - The rapid development PHP framework
![alt text](app.png?raw=true "app image")
- Wrap text with backticks. i.e.
index.js
git clone --depth=1 https://github.com/angular/angular-seed.git <your-project-name>
git commit -a -m 'message'
$ git commit --amend -m 'new message'
git reset HEAD~
git reset --hard 'your_commit_id'
git push -f -u origin master
git cherry -v
git cherry -v origin/somebranch
git rebase -i HEAD~N
- On VIM:
CW, esc, .
(this will change the desired word and period will repeat the previous actions) - Pass the desired flag before each commit message
- You may need to use
-f
when pushing if your rebased branch was previously pushed before
git commit --amend
git rm file_name
rm -rf .git
git rm -r --cached .idea
echo '.idea' >> .gitignore,
git rm -r --cached .idea,
git add .gitignore,
git commit -m 'your msg',
git push
rm -rf .git
git push -f -u origin master
git checkout -b <branch-name>
git branch -d <branch-name>
git push origin --delete branch-name
git branch -m <new_name>
git branch <branch-name>
git checkout <branch_name>
git branch ls-remote
git branch -a
git fetch
git branch
git log --all --decorate --oneline --graph
git log --oneline
git log
git log <filename>
git diff
git diff master ..branch-name
cat file_name
mkdir name && touch name/file.js
rm file_name
rm -r dir_name
mv file_name path
cd -
ctr l
cmd k
ctr u
ctr a
ctr e
ctl w
esc f
esc b
git checkout -- file_name
git checkout -- .
git reset HEAD file_name
git checkout master
git merge branch-name
git branch --merged
git merge branch-name
git merge --abort
git checkout (commit-hash)
git fetch upstream
git checkout -b explore-conflict upstream/master
git merge upstream/unmergeable-branch
git add file-name
,
git commit -m "fixed conflict"
ps: Create new branches when resolving conflicts
- Branches are cheap and disposable.
- Rather than risk messing up the branch you’ve been working on, create a new one specially for the purpose of discovering what sort of conflicts arise, and to give you a place to work on resolving them without disturbing your work so far.
git stash
git stash list
git stash list -p
git stash show
git stash show -p
git stash show -p stash@{1}
git stash apply
git stash list
git stash apply <label-name>
git stash pop
git stash save "message"
git stash clear
git pull --all
git checkout master
git fetch
git merge origin/master
git checkout master
git fetch upstream
git merge upstream/master
PS: Note that here instead of git fetch followed by git merge, you could have run git pull. The pull operation does two things: it fetches updates from your GitHub fork (origin), AND merges them. However, be warned that occasionally git pull won’t always work in the way you expect, and doing things the explicit way helps make what you are doing clearer. git fetch followed by git merge is generally the safer option.
fork > clone > branch > edit > stage > commit > push > pull request > merge
push origin <local-branch>
You could of course have merged your new branch into your master branch, and sent me a pull request from that. But, once again, it’s a good policy to keep your master branch, on GitHub too, clean of changes you make, and only to pull things into it from upstream.
In fact the same thing goes for other branches on my upstream that you want to work with. Keeping them clean isn’t strictly necessary, but it’s nice to know that you’ll always be able to pull changes from upstream without having to tidy up merge conflicts.
- This means that you have to unshallow your repository. To do so you will need to add your old remote again.
git remote add old <path-to-old-remote>
git fetch --unshallow old
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
git branch
git checkout master
git fetch
git merge origin/master
git checkout -b branch-name
git branch
git commit -am 'my message in present tense'
git push origin branch-name
git branch -r
The -p or --prune flag, after fetching, will remove any remote-tracking branches which no longer exist.
git fetch -p
git checkout my-feature-branch
git pull origin branch-name
Make sure that the feature branch is up to date with master, while in the feature branch, execrate the following:
git pull origin master
Now that I know that the feature branch is up to date with the remote repo and that it has the latest code from master, I can now merge these branches
git checkout master
git pull origin master
git merge --no-ff my-feature-branch
Notice the --no-ff flag in the merge command. This flag keeps the repo branching history from flattening out. If I were to look at the history of this branch, using GitX for example, when using the --no-ff flag, I will see the appropriate bump illustrating the history of the feature branch. This is helpful information. If I didn't use this flag, then Git will move the commit pointer forward.
Now that I have merged the code, the feature branch by definition is obsolete. First, delete the branch from the local repo.
git branch -d branch-name
If the feature branch was pushed to the repo, as it should have been per the workflow we described, you will want to delete this from the remote repo as well...
git push origin --delete my-feature-branch
AKA: Updates were rejected because the tip of your current branch is behind
This is a special case when working on a team and the branch I am are pushing is out of sync with the remote. To address this, it's simple, pull the latest changes:
git pull origin branch-name
git rm --cached <folder_name>
git add .
git commit -m "<your_message>"
git push --all
- Create the key
$ ssh-keygen -t rsa -C "[email protected]"
To accept the default path just hit Enter on your keyboard
- View the Public Key
$ cat ~/.ssh/id_rsa.pub
Your key will appear – copy the key text starting from ssh-rsa all the way to your username/host.
-
Add the Key to Your GitLab/GitHhub Profile
-
To avoid entering a passphrase everytime
$ ssh-add
- Fork the desired repo
- Check for the remote version
$ git remote -v
- Add the Main Repo (the one you forked from) as remote upstream
$ git remote add upstream 'main_repo_url'
- Pull latest upstream changes
$ git pull upstream master
- Pull latest upstream changes w/ rebase
$ git pull --rebase upstream master
- On VSC >GitLens:Compare Working Tree With...
- Choose desired option
- Set a Git username:
$ git config --global user.name "Mona Lisa"
- Confirm that you have set the Git username correctly:
$ git config --global user.name
> Mona Lisa - Repeat process for
$ git config --global user.email [email protected]
git reset --soft HEAD~1
- stash your changes
git reset --hard HEAD~10
- Merge Origin Master
- stash apply
- stage, commit and force push your branch